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 |
帮帮忙,看看错在哪里了。#include<stdio.h> int b[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int main() { int m=0,i=0,e,g,k,j,n,h; long a[1000]; int sum,nian,year; char s[7][11]={ "Saturday","Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"}; while(1) { scanf("%d",&a[i]); if(a[i]==-1) break; else { i++; m++; } } for(j=0;j<m;j++) { if(a[j]>365) { sum=0; for(year=2000;year<9999;) { nian=year; if(year%4==0&&year%100!=0||year%400==0) { sum+=366; } else { sum+=365; } if(a[j]-sum>365) year++; else { break; } } if((nian+1)%4==0&&(nian+1)%100!=0||(nian+1)%400==0) b[1]+=1; for(k=0;k<=11;) { if(a[j]-sum>b[k]) { sum+=b[k]; if(a[j]-sum>b[k+1]) { k++; g=k; continue; } else { g=k+1; e=a[j]-sum; break; } } else { g=k; e=a[j]-sum; break; } } n=a[j]%7; if(e==0||(e+1)==b[g+1]) printf("%d-%02d-%02d %s\n",nian+1,g+1,e+1,s[n]); else printf("%d-%02d-%02d %s\n",nian+1,g+1,e+j+1,s[n]); } else { nian=1999; sum=0; if((nian+1)%4==0&&(nian+1)%100!=0||(nian+1)%400==0) b[1]+=1; for(k=0;k<=11;) { if(a[j]-sum>b[k]) { sum+=b[k]; if(a[j]-sum>b[k+1]) { k++; g=k; continue; } else { g=k+1; h=a[j]-sum; break; } } else { g=k; h=a[j]-sum; break; } } n=a[j]%7; printf("%d-%02d-%02d %s\n",nian+1,g+1,h,s[n]); } } return(0); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator