(Culture: Chinese Zodiac) Simplify Listing ChineseZodiac.cpp using an array of strings to store the animal names.
Listing ChineseZodiac.cpp
1 #include2 using namespace std;34 int main()5 {6 cout << "Enter a year: "; ; 7 int year;8 cin >> year;910 switch (year % 12)11 {12 case 0 : cout << "monkey" << endl; break ;13 case 1 : cout << "rooster" << endl; break ;14 case 2 : cout << "dog" << endl; break ;15 case 3 : cout << "pig" << endl; break ;16 case 4 : cout << "rat" << endl; break ;17 case 5 : cout << "ox" << endl;break ;18 case 6 : cout << "tiger" << endl; break ;19 case 7 : cout << "rabbit" << endl; break ;20 case 8 : cout << "dragon" << endl; break ;21 case 9 : cout << "snake" << endl; break ;22 case 10 : cout << "horse" << endl; break ;23 case 11 : cout << "sheep" << endl; break ;24 }2526 return 0 ;27 }
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.