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 |
谁能帮我看看这段代码问题出在哪,谢谢啦!!/*Calendar*/ #include <stdio.h> int main() { long y,d,days,yearday,m[13],i; m[1]=31;m[2]=29;m[3]=31;m[4]=30;m[5]=31;m[6]=30; m[7]=31;m[8]=31;m[9]=30;m[10]=31;m[11]=30;m[12]=31; scanf("%ld",&days); while(days!=-1) { y=2000; m[2]=29; yearday=366; d=days; while(days>=yearday) { days=days-yearday; y++; if((y%100!=0)&&(y%4==0)||(y%400==0)) {m[2]=29; yearday=366; } else {m[2]=28; yearday=365; } } printf("%ld-",y); for(i=1;i<=12;i++) { if(days>=m[i]) days=days-m[i]; else break; } if(i<10) printf("0"); printf("%ld-",i); if(days<10) printf("0"); printf("%ld ",days+1); switch (d%7) { case 0: printf("Saturday\n"); break; case 1: printf("Sunday\n"); break; case 2: printf("Monday\n"); break; case 3: printf("Tuesday\n"); break; case 4: printf("Wednesday\n"); break; case 5: printf("Thursday\n"); break; case 6: printf("Friday\n"); break; } scanf("%ld",&days); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator