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 <iostream.h> #include <string.h> const int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int nexty,nextm,nextd; int leap(int year) { if ((year%4==0 && year%100!=0) || year%400==0) return 1; return 0; } int nextday(int year,int month,int day) { nexty=year; nextm=month; nextd=day+1; if (leap(year)){ if (month==2 && nextd>29){ nextd=1; nextm++; } } else if (day>m[month]){ nextd=1; nextm++; } if (nextm>12){ nextm=1; nexty++; } return 0; } int exist(int year,int month,int day) { if (year>101 || month>12) return 0; if (year==101 && (month>11 || day>4)) return 0; if (month==2 && leap(year)){ if (day>29) return 0; } else if (day>m[month]) return 0; return 1; } int main() { char f[105][15][35]; int i,j,k,test; int year,month,day; char flag1,flag2; memset(f,'0',sizeof(f)); f[101][11][3]='1'; for(i=101;i>=0;i--) for(j=12;j>=1;j--) for(k=31;k>=1;k--){ if (!exist(i,j,k)) continue; flag1='1'; flag2='1'; if (j==12) flag1=f[i+1][1][k]; else if (exist(i,j+1,k)) flag1=f[i][j+1][k]; nextday(i,j,k); if (exist(nexty,nextm,nextd)) flag2=f[nexty][nextm][nextd]; if (flag1=='0' || flag2=='0') f[i][j][k]='1'; } cin>>test; while(test--){ cin>>year>>month>>day; if (f[year-1900][month][day]=='1') cout<<"YES"<<endl; else cout<<"NO"<<endl; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator