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 |
Re:焦躁。。。不知道哪儿错了。。。disscuss里面给出的数据都过了。。。放弃了。。。In Reply To:焦躁。。。不知道哪儿错了。。。disscuss里面给出的数据都过了。。。放弃了。。。 Posted by:baiqi2piao at 2009-08-05 21:00:23 偶也是 #include<stdio.h> int a[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31, 0,31,29,31,30,31,30,31,31,30,31,30,31}; int c[2]={365,366}; char * week[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; int fun(int x) { if(x%400==0||x%4==0&&x%100!=0) return 1; else return 0; } int main() { int N; int year; int i; FILE * fp; fp=fopen("G:\\C++\\std.txt","r"); while(fscanf(fp,"%d",&N)&&N!=-1) { int WEEK; year=2000; WEEK=(6+N)%7; int k=fun(year); while(N>=c[k]) { N-=c[k]; year++; k=fun(year); } i=1; while(N>=a[k][i]) { N-=a[k][i]; i++; } int month=i--; int day; day=N+1; printf("%d-%02d-%02d %s\n",year,month,day,week[WEEK]); //fscanf(fp,"%d",&N); } fclose(fp); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator