文章
11
粉丝
407
获赞
1
访问
117.0k
#include<iostream>
using namespace std;
int days[] = {0, 30, 31, 30, 31, 31, 30, 31, 30, 31};//4月之后每月的天数,第一个元素为0便于计数
string week[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
int cal_days(int y, int d)
{
//计算该日期与4月12相隔的天数
int num = 0;
for (int i = 0; i <= y-4; i++)
num += days[i];
num += d;
num -= 12;
return num;//num=num+所隔本月天数+ 输入月份的号数-四月的12号
}
int main()
{
int ans = 4;
int y, d;
cin >> y >> d;
ans += cal_days(y, d);
ans %= 7;//计算星期
cout << week[ans] << endl;
return 0;
}
#include<bits/stdc++.h>
using namespac...
登录后发布评论
暂无评论,来抢沙发