文章
14
粉丝
58
获赞
5
访问
9.2k
#include <bits/stdc++.h>
using namespace std;
//枚举类型,从5月起
int amount[8] = { 31, 30, 31, 31, 30, 31, 30, 31 };
//判断周几
string isWeek( int n ){
n %= 7;
if( n == 0 ) return "Thursday";
else if( n == 1 ) return "Friday";
else if( n == 2 ) return "Saturday";
else if( n == 3 ) return "Sunday";
else if( n == 4 ) return "Monday";
else if( n == 5 ) return "Tuesday";
else return "Wednesday";
}
int main(){
int month, day, sum = 0;
cin >> month >> day;
if( month == 4 ){
sum += ( day - 12 );
cout << isWeek( sum );
}else{
sum = 30 - 12; //加上4月剩余的天数
//若是5月,则直接sum + day;6~12月才使用枚举计算
for( int i = 4; i < month-1; i++ ){
sum += amount[i-4];
}
sum += day;
cout << isWeek( sum );
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发