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 |
求帮助!!!!!测试数据都过了,但就是WA 哭.......不知道哪儿错了#include<stdio.h> //#include<math.h> int main() { long i,num,num_4,year,mon,day,week,k,m; long ping[12]={0,31,59,90,120,151,181,212,243,273,304,334}; long yun[12]={0,31,60,91,121,152,182,213,244,274,305,335}; while(1) { scanf("%d",&num); if( num==-1) break; k=num/(365*4+1); num_4=num - (365*4+1)*k; if( num_4<=365 ) m=0; else if( num_4<=366+365 ) m=1; else if( num_4<=366+365+365 ) m=2; else m=3; year=2000 + m + 4*k; if(num_4>365) { mon=(num_4-366)%365; for( i=0; i<12 && mon>=ping[i]; i++ ) ; day=mon-ping[i-1]+1; mon=i; } else { mon=num_4; for( i=0; i<12 && mon>=yun[i]; i++ ) ; day=mon-yun[i-1]+1; mon=i; } week=(num+6)%7; switch(week) { case 0: printf("%04d-%02d-%02d Sunday\n",year,mon,day);break; case 1: printf("%04d-%02d-%02d Monday\n",year,mon,day);break; case 2: printf("%04d-%02d-%02d Tuesday\n",year,mon,day);break; case 3: printf("%04d-%02d-%02d Wednesday\n",year,mon,day);break; case 4: printf("%04d-%02d-%02d Thursday\n",year,mon,day);break; case 5: printf("%04d-%02d-%02d Friday\n",year,mon,day);break; case 6: printf("%04d-%02d-%02d Saturday\n",year,mon,day);break; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator