#include "stdio.h"
#include "conio.h"
int fun2(int year,int month,int day)
{
int daynow,daysum,month2,monthdays=0;
if((year%4==0&&year%100!=0)||(year%400)==0)
month2=29;
else
month2=28;
switch(month)
{
case 1:
daynow=31;
daysum=0;
break;
case 2:
daysum=31;
break;
case 3:
daynow=31;
daysum=month2+31;
break;
case 4:
daynow=30;
daysum=month2+62;
break;
case 5:
daynow=31;
daysum=month2+92;
break;
case 6:
daynow=30;
daysum=month2+123;
break;
case 7:
daynow=31;
daysum=month2+153;
break;
case 8:
daynow=31;
daysum=month2+184;
break;
case 9:
daynow=30;
daysum=month2+215;
break;
case 10:
daynow=31;
daysum=month2+245;
break;
case 11:
daynow=30;
daysum=month2+276;
break;
case 12:
daysum=month2+306;
break;
}
monthdays=daysum+day-1;
//printf("monthdays=%d\n",monthdays);//用来测试
return(monthdays);
}
long fun1(int year)
{
long yeardays;
yeardays=(year-1990)*365+(year-1990)/4-(year-1990)/100+(year-1990)/400;
//printf("yeardays=%d\n",yeardays);
return(yeardays);
}
int main(void)
{
int year,month,day;
long alldays;
int mod;
printf("****************************************************\n");
printf("中国有句古话叫【三天打鱼两天晒网】\n");
printf("某人从1990年1月1日开始【三天打鱼两天晒网】\n");
printf("问这个人在输入的某一天里是【打鱼】还是【晒网】?\n");
printf("****************************************************\n");
while(1)
{
printf("请输入年-月-日:");
scanf("%d-%d-%d",&year,&month,&day);
if(year<1990||year>9999||month<=0||month>12||day<=0||day>31)
{
printf("无效的日期,退出程序。\n");
return 0;
}
alldays=fun1(year)+fun2(year,month,day);
//printf("alldays=%d\n",alldays);
mod=alldays%5;
//printf("mod=%d\n",mod);
switch(mod)
{
case 1:
case 2:
case 3:
printf("这天在打鱼!\n");
getch();
break;
case 0:
case 4:
printf("这天在晒网!\n");
getch();
break;
}
}
return 0;
}