#include<stdio.h>
int getDaya(int year);
int getDayb(int year,int month,int day);
int main ()
{
int year,month,day,x,y;
printf("请输入年月日\n");
//year=2002;month=2;day=2;
scanf("%d%d%d",&year,&month,&day); //又一次忘了加&
x=getDaya(year)+getDayb(year,month,day);
y=x%5;
switch(y)
{
case 0 : printf("今日在休息");break;
case 1 : printf("今日在打鱼");break;
case 2 : printf("今日在打鱼");break;
case 3 : printf("今日在打鱼");break;
case 4 : printf("今日在休息");break;
}
}
int getDaya(int year)
{
int suma=0,i,j=0;
suma=(year-2000)*365;
for(i=2000;i<=year;i++)
{
if(i%4==0 && i%100!=0 || i%400==0)
j++;
}
suma=suma+j;
return suma;
}
int getDayb(int year,int month,int day)
{
int a[100]={31,28,31,30,31,30,31,31,30,31,30,31};
int sumb=0,i;
if((year%4==0 && year%100!=0)|| (year%400==0))
a[1]=29;
for(i=0;i<month-1;i++)
{
sumb+=a[i];
}
sumb+=day;
return sumb;
int getDaya(int year);
int getDayb(int year,int month,int day);
int main ()
{
int year,month,day,x,y;
printf("请输入年月日\n");
//year=2002;month=2;day=2;
scanf("%d%d%d",&year,&month,&day); //又一次忘了加&
x=getDaya(year)+getDayb(year,month,day);
y=x%5;
switch(y)
{
case 0 : printf("今日在休息");break;
case 1 : printf("今日在打鱼");break;
case 2 : printf("今日在打鱼");break;
case 3 : printf("今日在打鱼");break;
case 4 : printf("今日在休息");break;
}
}
int getDaya(int year)
{
int suma=0,i,j=0;
suma=(year-2000)*365;
for(i=2000;i<=year;i++)
{
if(i%4==0 && i%100!=0 || i%400==0)
j++;
}
suma=suma+j;
return suma;
}
int getDayb(int year,int month,int day)
{
int a[100]={31,28,31,30,31,30,31,31,30,31,30,31};
int sumb=0,i;
if((year%4==0 && year%100!=0)|| (year%400==0))
a[1]=29;
for(i=0;i<month-1;i++)
{
sumb+=a[i];
}
sumb+=day;
return sumb;
}
第一次运行之后 输入后直接进入死循环,后发现又忘了加&