#include
#include
using namespace std;
string weekday[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
bool is_leap_year(int y){
if((y % 4 == 0 && y % 100 != 0 ) || (y % 400 == 0)){
return true;
}else{
return false;
}
}
int whatday1(int y,int m,int d){
int ans = 0;
for(int i = 1;i < y;i++){
cout << "year=" << i << endl;
if(is_leap_year(i)){
cout << "" << endl;
ans += 366;
}else{
ans += 365;
}
}
for(int i = 1;i < m;i++){
cout << "month=" << i << endl;
if(i == 1 || i == 3 || i == 5 || i == 7 || i == 8 || i == 10 || i == 12){
ans += 31;
}else if(i == 4 || i == 6 || i == 9 || i == 11){
ans += 30;
}else if(is_leap_year(y)){
ans += 29;
}else{
ans += 28;
}
}
ans += d-1;
ans %= 7;
return ans;
}
int whatday(int y,int m,int d){
if (m == 1 || m == 2) {
m += 12;
y--;
}
return (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7;
}
int main(){
int y,m,d;
cin >> y >> m >> d;
//cout << is_leap_year(y) << endl;
cout << weekday[whatday1(y,m,d)] << endl;
return 0;
}
一键复制
编辑
Web IDE
原始数据
按行查看
历史