用C语言生成一个生生肖推算的代码
时间: 2023-04-08 11:04:47 浏览: 123
我可以回答这个问题。以下是一个用C语言生成生肖推算的代码示例:
#include <stdio.h>
int main() {
int year;
printf("请输入出生年份:");
scanf("%d", &year);
switch (year % 12) {
case 0:
printf("你的生肖是猴\n");
break;
case 1:
printf("你的生肖是鸡\n");
break;
case 2:
printf("你的生肖是狗\n");
break;
case 3:
printf("你的生肖是猪\n");
break;
case 4:
printf("你的生肖是鼠\n");
break;
case 5:
printf("你的生肖是牛\n");
break;
case 6:
printf("你的生肖是虎\n");
break;
case 7:
printf("你的生肖是兔\n");
break;
case 8:
printf("你的生肖是龙\n");
break;
case 9:
printf("你的生肖是蛇\n");
break;
case 10:
printf("你的生肖是马\n");
break;
case 11:
printf("你的生肖是羊\n");
break;
}
return 0;
}