题意:求某天是星期几。
题解:数学||模板
View Code
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 char name[][12] = { "monday", "tuesday", "wednesday", 6 "thursday", "friday", "saturday", "sunday" 7 }; 8 int main(void) 9 { 10 int d, m, y, a; 11 while(scanf("%d%d%d",&y,&m,&d)!=EOF) 12 { 13 if (m==1||m==2) 14 { 15 m+=12; 16 y--; 17 } 18 if((y<1752)||(y==1752&&m<9)||(y==1752&&m==9&&d<3)) 19 a=(d+2*m+3*(m+1)/5+y+y/4+5)%7; 20 else 21 a=(d+2*m+3*(m+1)/5+y+y/4-y/100+y/400)%7; 22 puts(name[a]); 23 } 24 return 0; 25 }