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:纯属误导!大家勿信 只需留意判断400年 Posted by:kiro3322 at 2011-02-15 14:41:08 #include <stdio.h> int isleap(int y) { if (y%4) return 0; if ((!(y%100)) && (y%400)) return 0; return 1; } int getds(int ds[],int y,int m) { if (m!=2) return ds[m];else return isleap(y)?29:28; } int getdy(int y) { return isleap(y)?366:365; } int main() { int n,i,j,temp; int ds[13]={0,31,(1<<16),31,30,31,30,31,31,30,31,30,31}; char* weekday[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; while (scanf("%d",&n)>=1&&n!=-1) { int y=2000,m=1; j=n-1;n++; while (n>(temp=getdy(y))) {n-=temp;y++;} while (n>(temp=getds(ds,y,m))) {n-=temp;m++;if (m==13) {m=1;y++;}} printf("%04d-%02d-%02d %s\n",y,m,n,weekday[j%7]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator