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 33 34 35 36
|
#include <iostream>
int main()
{
const int BASE_YEAR = 1924 ;
int year ;
std::cout << "what year were you born in? " ;
std::cin >> year ;
if( year < BASE_YEAR ) std::cout << "you are too old\n" ;
else if( year > 2019 ) std::cout << "wait till you are born\n" ;
else
{
const int delta = year - BASE_YEAR ;
switch(delta%12)
{
case 0 : // year is one of 1924, 1936, 1948, 1960, 1972, 1984, 1996, 2008
std::cout << "Your lucky Chinese Zodiac Animal is Pig\n"
"Your personality could be quick-witted, resourceful, versatile and kind.\n" ;
break ;
case 1 : // year is one of 1925, 1937, 1949, 1961, 1973, 1985, 1997, 2009
std::cout << "Your lucky Chinese Zodiac Animal is Ox\n"
"Your personality could be diligent, dependable, strong and determined.\n" ;
break ;
// etc.
}
}
}
| |