#include<stdio.h>
#define YEAR 1990
#define MONTH 1
int mian()
{
int year,month,day,i=0;
int y=0,m=0,len=0;
printf("please input year month and day\n");
while(!i)
{
scanf("%d%d%d",&year,&month,&day);
if(year<YEAR||month>12||month<1||day>31||day<1)
printf("data error,please input the right numbers\n");
else i=1;
}
month=month-1;
while(month>=1)
{
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:m=31;break;
case 4:
case 6:
case 9:
case 11:m=30;break;
case 2:
{
if((year%4==0&&year%100!=0)||(year%400==0))
m=29;
else m=28;
}
month--;
len=m+len;
}
}
if(year>YEAR)
y=(year-YEAR)*365;
else y=0;
len=len+y+day;
if(len%5==0||(len+1)%5==0)
printf("he is having a rest.\n");
else printf("he is working.\n");
return 0;
}
#include<stdio.h>
#define YEAR 1990
#define MONTH 1
int main() //main不是mian
{
int year,month,day,i=0;
int y=0,m=0,len=0;
printf("please input year month and day\n");
while(!i)
{
scanf("%d%d%d",&year,&month,&day);
if(year<YEAR||month>12||month<1||day>31||day<1)
printf("data error,please input the right numbers\n");
else i=1;
}
month=month-1;
while(month>=1)
{
month--; //改!
switch(month + 1) //改
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:m=31;break;
case 4:
case 6:
case 9:
case 11:m=30;break;
case 2:
{
if((year%4==0&&year%100!=0)||(year%400==0))
m=29;
else m=28;
}
len=m+len;
}
}
if(year>YEAR)
y=(year-YEAR)*365;
else y=0;
len=len+y+day;
if(len%5==0||(len+1)%5==0)
printf("he is having a rest.\n");
else printf("he is working.\n");
return 0;
}
如果问题得到解决,请点我回答左上角的向上箭头和采纳,谢谢