SWUSTOJ78
题目描述
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/62b6bc0edb7136c0565d76866b88dafb.png)
输入
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/76718bbe6eb87a8f3925d55ab3175c2e.png)
输出
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/d881a6e0f56a81abd819acf68b3a44ac.png)
样例输入
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/94a652384802968c33b92bcb8e8ab3fc.png)
样例输出
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/eb4783ceee2b76088f2c3c5c330a2076.png)
源代码
#include<stdio.h>
int main()
{
int year,month,day,allday;
int i,j;
while(scanf("%d %d %d",&year,&month,&day)!=EOF)
{
allday=0;
for(i=1;i<year;i++)
{
if((i%4==0 && i%100!=0) ||(i%400==0))
{
allday+=366;
}
else
{
allday+=365;
}
}
for(i=1;i<month;i++)
{
if(i==2)
{
if((year%4==0 && year%100!=0) ||(year%400==0))
{
allday+=29;
}
else
{
allday+=28;
}
}
else if(i==1||i==3||i==5||i==7||i==8||i==10||i==12)
{
allday+=31;
}
else
{
allday+=30;
}
}
allday+=day;
j=allday%7;
switch(j)
{
case 0:printf("Sunday\n");break;
case 1:printf("Monday\n");break;
case 2:printf("Tuesday\n");break;
case 3:printf("Wednesday\n");break;
case 4:printf("Thursday\n");break;
case 5:printf("Friday\n");break;
case 6:printf("Saturday\n");break;
}
}
return 0;
}