#include <stdio.h>
main()
{
int a[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31 ,30,31,30,31}}; /*定义一个二维数组,闰年,平年12个月每个月的天数*/
int m,n,year,month,day,i,tyear;
int total=0;
printf("please input a date:");
scanf("%d %d %d",&year,&month,&day);
for(tyear=1990; tyear<year; tyear++)
{
if(tyear%4==0&&tyear%100!=0||tyear%400==0) /*判断是平年还是闰年,并把输入年前几年的天数相加*/
total+=366;
else
total+=365;
}
m=year%4==0&&year%100!=0||year%400==0;
for(n=0; n<=(month-2); n++)
{
total+=a[m][n]; /*将输入年前面几个月的天数相加*/
}
total+=day; /*将当前月的天数加上去*/
i=total%5;
if(i>0&&i<4)
printf("he was fishing at that day.\n"); /*判断是打鱼还是晒网*/
else
printf("he was sleeping at that day.\n");
}
main()
{
int a[2][12]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31 ,30,31,30,31}}; /*定义一个二维数组,闰年,平年12个月每个月的天数*/
int m,n,year,month,day,i,tyear;
int total=0;
printf("please input a date:");
scanf("%d %d %d",&year,&month,&day);
for(tyear=1990; tyear<year; tyear++)
{
if(tyear%4==0&&tyear%100!=0||tyear%400==0) /*判断是平年还是闰年,并把输入年前几年的天数相加*/
total+=366;
else
total+=365;
}
m=year%4==0&&year%100!=0||year%400==0;
for(n=0; n<=(month-2); n++)
{
total+=a[m][n]; /*将输入年前面几个月的天数相加*/
}
total+=day; /*将当前月的天数加上去*/
i=total%5;
if(i>0&&i<4)
printf("he was fishing at that day.\n"); /*判断是打鱼还是晒网*/
else
printf("he was sleeping at that day.\n");
}