文章

49

粉丝

90

获赞

90

访问

38.0k

头像
日期 题解:C++
P1011 贵州大学机试题
发布于2024年3月8日 19:22
阅读数 759

#include<iostream>
#include <string>
using namespace std;

const int s[12] = { 30,31,30,31,31,30,31,30,31 };
const string w[7] = { "Friday" ,"Saturday" ,"Sunday","Monday" ,"Tuesday" ,"Wednesday" ,"Thursday" };

int dif_day(int m, int d)
{
	int x = 0;
	m -= 4;
	while (m)
	{
		x += s[--m];
	}
	x += d;
	x -= 12;
	return x;
}

int main()
{
	int  m, d;
	int dif;
	cin >> m >> d;
	dif = dif_day(m, d);
	dif %= 7;
	if (dif == 0)
	{
		cout << w[6] << endl;
	}
	else
	{
		cout << w[dif - 1] << endl;
	}
	return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发