标签:
#include<stdio.h> int f[13] ={0,31,28,31,30,31,30,31,31,30,31,30,31}; int is_leapyear(int Y){ if(Y%4==0&&Y%100!=0||Y%400==0) return 1; return 0; } int DAY(int Y,int M,int D){ int i,days=0; for(i=1;i<M;++i){ days+=f[i]; } days+=D; if(is_leapyear(Y)&&M>2) days++; return days; } int main(){ int year,month,day; while(~scanf("%d%d%d",&year,&month,&day)){ int dd=0,xq; if(year>2011||year==2011&&month>11||year==2011&&month==11&&day>=11) { for(int i=2011;i<year;++i){ dd+=365; if(is_leapyear(i)) dd++; } dd+=DAY(year,month,day); dd-=DAY(2011,11,11); //????? xq=(5+dd)%7; //星期 } else { //已2012 1 1 为 标准量值 for(int i=year+1;i<=2011;++i){ dd+=365; if(is_leapyear(i)) dd++; } dd-=365-DAY(2011,11,11); dd+=365-DAY(year,month,day); if(is_leapyear(year)) dd++; //printf("%d\n",dd); //printf("星期:%d\n",(5-(dd)%7+7)%7) ; xq=(5-dd%7+7)%7; } if(xq==0) printf("7\n"); else printf("%d\n",xq); } return 0; }
标签:
原文地址:http://blog.csdn.net/qq_18062811/article/details/44497711