Chinese Zodiac

描述

The Shengxiao, better known in English as the Chinese Zodiac, is a scheme that relates each year to an animal and its reputed attributes, according to a 12-year cycle. The zodiac traditionally begins with the sign of the Rat, and the twelve zodiac signs are Rat, Ox, Tiger, Rabbit, Dragon, Snake, Horse, Ram, Monkey, Rooster, Dog and Pig. The zodiac signs cycles continuously, and determines the animal or sign under which a person is born. This year (2011, more accurately Chinese Xin Mao Year – 3 February 2011 - 22 January 2012) is the Chinese Year of the Rabbit, so the babies born in this year are said to be born under the Chinese Zodiac sign of the Rabbit.

In China, Xusui, also known as east Asian age reckoning, is used to count a person’s age. Newborns start at one year old, and each passing of a Lunar New Year, rather than the birthday, adds one year to the person’s age. In other words, the first year of life is counted as one instead of zero, so that a person is two years old in their second year, three years old in their third, and so on.

Given the traditional age (Xusui) of someone, you are requested to answer his zodiac sign (Shengxiao).
输入

There are multiple test cases. The first line of input is an integer T ≈ 1000 indicating the number of test cases.

Each test case contains only one positive integer y ≤ 200 – the traditional age.

输出

For each test case, output a string – the zodiac sign.

样例输入

5
1
23
40
100
160

样例输出

Rabbit
Snake
Rat
Rat
Rat
分析:生肖问题,根据输入输出样例找到规律。
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
string s[]={“Dragon”,“Rabbit”,“Tiger”,“Ox”,“Rat”,“Pig”,“Dog”,“Rooster”,“Monkey”,“Ram”,“Horse”,“Snake”};
cin>>T;
while(T–)
{
int m;
cin>>m;
cout<<s[m%12]<<endl;
}
return 0;
}

发布了40 篇原创文章 · 获赞 0 · 访问量 686

猜你喜欢

转载自blog.csdn.net/Skynamer/article/details/103403504
今日推荐