#include #include #include #include using namespace std; int main() { time_t t {time(nullptr)}; tm *p {localtime(&t)}; int currentYear {p->tm_year + 1900}; string animal[] { "monkey", "rooster", "dog", "pig", "rat", "ox", "tiger", "hare", "dragon", "snake", "horse", "sheep" }; int n {sizeof animal / sizeof animal[0]}; cout << "Please type a year: "; int year {0}; cin >> year; if (!cin) { cerr << "Sorry, that wasn't a number.\n"; return EXIT_FAILURE; } if (year <= 0) { cerr << "Sorry, the year has to be a positive number.\n"; return EXIT_FAILURE; } if (year < currentYear) { cout << year << " was the year of the" << animal[year % n] << ".\n"; }else if (year > currentYear) { cout << year << " will be the year of the" << animal[year % n] << ".\n"; }else { cout << year << " is the year of the" << animal[year % n] << ".\n"; } }