1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
bool isR(int year) {
// if(year % 4==0) {
// // if(year%100) return true;
// }
// return year%400 ==0;
return year % 4 == 0 && year % 100 || year % 400 == 0;
}
unordered_map<string,int> mont =
{ {"January",1},
{"February",2}
,
{"March",3},{ "April",4},{ "May",5},
{"June",6},
{"July",7},
{"August",8},
{"September",9}
, {"October",10},{ "November",11},
{"December",12}
};
//2月一般就是 28天,闰年 改成 29天
int months[] = {
0,31,28, 31,30,31,30,31,31,30,31,30,31
};
int getMonth(string &x) {
return mont[x];
// for(int i=0;i<12;++i) {
// if(month[i]==x) return i+1;
// }
// cout<<"error " <<endl;
// return -1;
}
int get_days(int year,int month) {
int s = months[month];
if(month==2) {
if(isR(year)) {
//是闰年的话 ,改成 29天
return s+1;
}
}
return s;
}
string weeks[] = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"};
int main(void) {
int day,year;
string month;
while(cin>> day >> month >> year) {
int days = 0;
// if(isR(year)) {
// days = (getMonth(month)-1)*30;
// //
// if(year>2) days-=1;
// }else{
// days = ( getMonth(month) -1)*30;
// }
//第几个月份
int m = getMonth(month);
int yi =1,mi=1,di = 1;
while(yi< year || mi < m || di<day) {
di++,days++;
if(di > get_days(yi,mi)) {
di = 1;
//月份++
mi++;
if(mi>12) {
mi = 1;
yi++;
}
}
}
// days %=7;
cout << weeks[ days % 7] <<endl;
}
return 0;
}
|