Description
Input
Output
Sample Input
Sample Output
1 #include <iostream> 2 #include <stdio.h> 3 #include <cstring> 4 using namespace std; 5 int a[]={0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 6 int b[]={0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 7 char c[8][11]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}; 8 int panduan(int y) 9 { 10 if((y%4==0 && y%100!=0) || y%400==0) 11 return 1; 12 return 0; 13 } 14 int main() 15 { 16 int y, m, d, sum, i; 17 while(cin>>y>>m>>d) 18 { 19 if(panduan(y)) 20 { 21 if(d>b[m]||m==0||d==0) 22 { 23 cout << "illegal" << endl; 24 continue; 25 } 26 } 27 else 28 { 29 if(d>a[m]||m==0||d==0) 30 { 31 cout << "illegal" << endl; 32 continue; 33 } 34 } 35 sum=0; 36 for (i=1; i<y; ++i) 37 { 38 if(panduan(i)) 39 sum += 366; 40 else 41 sum += 365; 42 43 } 44 for(int i = 0; i < m; ++i) 45 { 46 if(panduan(y)) 47 sum += b[i]; 48 else 49 sum += a[i]; 50 51 } 52 sum+=d; 53 sum%=7; 54 cout<< c[sum] << endl; 55 } 56 return 0; 57 }