Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
对着数据测了一遍,,发现没错,还有什么要考虑的吗??再次麻烦老大。。。。In Reply To:悲哀……对着日历都对过了,结果还是WA Posted by:realmajia at 2005-06-04 02:59:12 #include<stdio.h> void main() { int t1[12]={31,28,31,30,31,30,31,31,30,31,30,31}, t2[12]={31,29,31,30,31,30,31,31,30,31,30,31}; char qx[7][15]={"Friday","Saturday","Sunday", "Monday", "Tuesday", "Wednesday","Thursday"}; int n,k,y,m,d,i,xq; while(1) { scanf("%d",&n); if(n==-1) break; n+=1; y=2000;m=1;d=1; k=n; while(1) { if((y%4==0&&y%100!=0&&k>366)||(y%400==0&&k>366)) { k=k-366;y++; } else if(k>365) { k=k-365;y++; } else break; } if((y%4==0&&y%100!=0)||(y%400==0)) { for(i=0;;i++) if(k>t2[i]) {k=k-t2[i];m++;} else break; } else { for(i=0;;i++) if(k>t1[i]) {k=k-t1[i];m++;} else break; } xq=n%7; d=k; if(m<10&&d<10) printf("%d-0%d-0%d %s\n",y,m,d,qx[xq]); else if(m>=10&&d<10) printf("%d-%d-0%d %s\n",y,m,d,qx[xq]); else if(m<10&&d>=10) printf("%d-0%d-%d %s\n",y,m,d,qx[xq]); else printf("%d-%d-%d %s\n",y,m,d,qx[xq]); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator