可以运行,但是结果有点奇怪,求助~
程序代码:#include <stdio.h>
int main()
{
int year,month,day,a,alldays,c;
printf("请输入年月日:xxxx.x.x\n");
scanf("%d.%d.%d",&year,&month,&day);
switch(month)
{
case 1:a=0;break;
case 2:a=31;break;
case 3:a=59;break;
case 4:a=90;break;
case 5:a=120;break;
case 6:a=151;break;
case 7:a=181;break;
case 8:a=212;break;
case 9:a=243;break;
case 10:a=273;break;
case 11:a=304;break;
case 12:a=334;break;
}
if((year%4==0) && (month>2))
{
alldays=a+day+1;
c=alldays%5;
if(1 <= c <= 3)
{
printf("这个人在打渔");
}
if((c == 4)&&(c == 0))
printf("这个人在晒网");
}
else
{
alldays=a+day;
c=alldays%5;
if(1 <= c <=3)
{
printf("这个人在打渔");
}
if((c == 4)&&(c == 0))
printf("这个人在晒网");
}
getchar();
getchar();
return 0;
}
1、 一、中国有句俗语叫“三天打鱼两天晒网”。某人从每年1月1日起开始“三天打鱼两天晒网”,问这个人在该年的某一天是“打鱼”还是“晒网”。
无论输入什么年月日 结果都是打渔。。。自己找不到是哪个地方有问题。。。







