回复 5楼 逍风
我改了下,但大部分主题还是你的建议:
#include<stdio.h>
#include <windows.h>
void test(int year, int m, int d);
int main()
{
int year, cha, m, d,choose;
printf("\n");
printf("输入出生年份,月份及日期:");
scanf("%d %d %d", &year, &m, &d);
test(year, m, d);
scanf("%d", &choose);
if (choose == 1)
main();
else
exit(0);
}
void test(int year, int m, int d)
{
int choose;
int cha;
cha = (year - 1985) % 12;
if (cha < 0)
cha = 12 + cha;
switch (cha)
{
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;
}
switch (m)
{
case 1:{if (d < 20)
printf("星座:魔蝎座\n");
else
printf("星座:水瓶座\n");
break; }
case 2:{if (d < 19)
printf("星座:水瓶座\n");
else
printf("星座:双鱼座\n");
break; }
case 3:{if (d < 21)
printf("星座:双鱼座\n");
else
printf("星座:白羊座\n");
break; }
case 4:{if (d < 20)
printf("星座:白羊座\n");
else
printf("星座:金牛座\n");
break; }
case 5:{if (d < 21)
printf("星座:金牛座\n");
else
printf("星座:双子座\n");
break; }
case 6:{if (d < 22)
printf("星座:双子座\n");
else
printf("星座:巨蟹座\n");
break; }
case 7:{if (d < 23)
printf("星座:巨蟹座\n");
else
printf("星座:狮子座\n");
break; }
case 8:{if (d < 23)
printf("星座:狮子座\n");
else
printf("星座:处女座");
break; }
case 9:{if (d < 23)
printf("星座:处女座\n");
else
printf("星座:天秤座\n");
break; }
case 10:{if (d < 24)
printf("星座:天秤座\n");
else
printf("星座:天蝎座\n");
break; }
case 11:{if (d < 23)
printf("星座:天蝎座\n");
else
printf("星座:射手座\n");
break; }
case 12:{if (d < 22)
printf("星座:射手座\n");
else
printf("星座:魔蝎座\n");
break; }
}
printf("\n");
printf("是否继续查询:1.继续 0.取消:");
}