输入一个年份计算生肖
#include<stdio.h>
int main(){
int year;
scanf("%d", &year);
char arr[12][20]={ "rat", "ox", "tiger", "rabbit", "dragon", "snake", "horse",
"sheep", "monkey", "rooster", "dog", "pig"};
if(year == 1900){
printf("rat");
return 0;
}
if(year > 1900){
year = year - 1900;
year = year % 12;
printf("%s", arr[year]);
return 0;
}
if(year < 1900){
year = (year - 1900) * -1;
year = year % 12;
year = 12 - year;
printf("%s", arr[year]);
}
return 0;
}