hdu2133: 题意(解法):已知0年1月1日是周6,输入一个日期,问星期几code:
#include #include #include #include int tianshu1[]={ 31,28,31,30,31,30,31,31,30,31,30,31};int tianshu2[]={ 31,29,31,30,31,30,31,31,30,31,30,31};char tab[7][10]={ "Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"};bool runnian(int n){ if((n%4==0&&n%100!=0)||n%400==0) return true; else return false;}int main(){ int y,m,d; while(scanf("%d%d%d",&y,&m,&d)!=EOF) { int ans=0; if(m==0||d==0||(!runnian(y)&&d>tianshu1[m-1])||(runnian(y)&&d>tianshu2[m-1])) { printf("illegal\n"); continue; } for(int i=0;i