1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#include <iostream>
void print_period_names( int start, int end )
{
constexpr int N = 12 ;
static const char* const period_name[N] =
{
"Neogene", "Paleogene", "Cretaceous", "Jurassic", "Triassic", "Permian",
"Carboniferous", "Devonian", "Silurian", "Ordovician", "Cambrian", "Precambrian"
};
static const int period_max[N] =
{
65, 135, 192, 225, 280, 345, 395, 435, 500, 570, 4500, 99999999
};
if( start<999999 && end>start )
{
int s = 0 ;
while( start > period_max[s] ) ++s ;
int f = N-1 ;
while( end < period_max[f] ) --f ;
for( int i = s ; i <= f ; ++i ) std::cout << period_name[i] << '\n' ;
}
}
int main()
{
print_period_names( 395, 4500 ) ;
}
|