标签:
链接http://acm.swust.edu.cn/problem/0078/
#include <stdio.h> bool LeapYear(int year) { return((year%400==0)||(year%100!=0&&year%4==0)); } int main() { int i; int year,month,day; int sum; int monthday[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; while(~scanf("%d %d %d",&year,&month,&day)) { sum=day; for(i=1;i<year;i++) { if(LeapYear(i)) { sum+=366; } else { sum+=365; } } if(LeapYear(year)) { monthday[2]=29; } for(i=1;i<month;i++) { sum+=monthday[i]; } monthday[2]=28; //printf("%d\n",sum); switch(sum%7) { 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; case 0:printf("Sunday\n");break; } } return 0; }
标签:
原文地址:http://www.cnblogs.com/niconiconi/p/5720520.html