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> #include<string.h> #define p 1 #define r 0 int years,months,days; int year_p_r(int n) { if(n%400==0||(n%100!=0&&n%4==0)) return r; return p; } void date(int n) { int i; int ping[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int run[12]={31,29,31,30,31,30,31,31,30,31,30,31}; years=2000; while(n>=366) { if(year_p_r(years)==r) n-=366; else n-=365; years++; } if(year_p_r(years)==p&&n>=365) { n-=365; years++; } if(year_p_r(years)==p) { int i; for(i=0;i<12;i++) { n-=ping[i]; if(n<=0) break; } months=i+1; days=n+ping[i]+1; } else { for(i=0;i<12;i++) { n-=run[i]; if(n<=0) break; } months=i+1; days=n+run[i]+1; } } int week_n(int n) { n+=6; n%=7; return n; } int main() { int n; char week[7][12]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; scanf("%d",&n); while(n+1) { date(n); printf("%04d-%02d-%02d ",years,months,days); puts(week[week_n(n)]); scanf("%d",&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