这是哪错了/(ㄒoㄒ)/~~简单,但本蒟蒻看不出问题
查看原帖
这是哪错了/(ㄒoㄒ)/~~简单,但本蒟蒻看不出问题
1347243
JYF_go楼主2024/8/31 12:55

代码 C++ (+O2)

#include<bits/stdc++.h>
using namespace std;
int Month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int n, now = 1;
int day=1, month=1, year=1990;
int Week[8];
int Nextday1()
{
    return now==7?1:now+1;
}
int Nextmonth()
{
    if(month==12)
	{
		year ++;
		return 1;
	}
	return month + 1;
}
int Nextday2()
{
    if(day==Month[month])
	{
		month = Nextmonth();
		return 1;
	}
	return day + 1;
}

bool isRun()
{
	if(year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
		return 1;
	return 0;
}
int main()
{
    cin >> n;
    while(year < 1990 + n)
    {

//        printf("%d年%d月%d日   星期%d\n", year, month, day, now);
    	isRun()?Month[2] = 29:Month[2] = 28;
    	now = Nextday1();
    	day = Nextday2();
    	if(day == 13)
    		Week[now] ++;
    	
	}
	cout << Week[6] << " " << Week[7] << " " << Week[1] << " " << Week[2] << " " << Week[3] << " " << Week[4] << " " << Week[5] << " ";
	return 0;
}

求调~~~

2024/8/31 12:55
加载中...