1990-1-1开始上班
办法非常蠢,懒得改了,记录一下
#include<stdio.h>
#include<math.h>
int IsLeapYear(int n);
int main()
{
int year,month,days;
int check01,check02=1;
int detyear,i;
check01=scanf("%4d-%2d-%2d",&year,&month,&days);
if(month==1||3==month||5==month||7==month||8==month||10==month)
{
if(days>31||days<=0)
{
check02=0;
}
}
if(4==month||6==month||9==month||11==month||12==month)
{
if(days>30||days<=0)
{
check02=0;
}
}
if(2==month)
{
if(IsLeapYear(year))
{
if(days>29||days<=0)
check02=0;
}
else
{
if(days>28||days<=0)
check02=0;
}
}
if(check01!=3||year<1990||month>=13||month<=0||check02==0)
{
printf("Invalid input");
return 0;
}
detyear=year-1990;
int detdate=0;
for(i=1;i<=detyear;i++)
{
if(IsLeapYear(1990+i-1))
detdate+=366;
else
detdate+=365;
}
for(i=1;i<month;i++)
{
if(1==i||i==3||i==5||i==7||8==i||10==i)
{
detdate+=31;
}
else if(4==i||6==i||9==i||11==i||12==i)
{
detdate+=30;
}
else if(2==i)
{
if(IsLeapYear(year))
{
detdate+=29;
}
else
{
detdate+=28;
}
}
}
detdate+=days-1;
printf("%d",detdate);
int mark;
mark=detdate%5;
if(mark<=3)
{
printf("He is working");
}
else
{
printf("He is having a rest");
}
return 0;
}
int IsLeapYear(int n)
{
if(n%4==0&&n%100!=0||n%400==0)
return 1;
else
return 0;
}