那位大佬可以帮我看一下错那了????
查看原帖
那位大佬可以帮我看一下错那了????
660945
D3ath楼主2022/11/2 22:05
#include<iostream>
using namespace std;
int main()
{
	int s[2][12] = { {0,31,28,31,30,31,30,31,31,30,31,30},
					 {0,31,29,31,30,31,30,31,31,30,31,30} };
	int n, a[7] = { 0 };
	cin >> n;
	int t=1,y = 1990;
	for (int i = 0; i < n; i++)
	{
		if (i == 0)
		{
			t = (t + 12) % 7;
			a[t]++;
		}
		else
		{
			t = (t + 31) % 7;
			a[t]++;
		}
		if (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0))
		{
			for (int j = 1; j < 12; j++)
			{
				t = (t + s[1][j]) % 7;
				a[t]++;
			}
		}
		else
		{
			for (int j = 1;j < 12; j++)
			{
				t = (t + s[0][j]) % 7;
				a[t]++;
			}
		}
		y++;
	}
	cout << a[6] << " " << a[0] << " ";
	for (int i = 1; i <= 5; i++)
		cout << a[i] << " ";
	return 0;
}
2022/11/2 22:05
加载中...