AcWing no. 2020第十一届蓝桥杯CC++B组省赛 跑步锻炼
原题链接
简单
作者:
愿无忧
,
2021-02-27 00:42:29
,
所有人可见
,
阅读 633
C++ 代码
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int months[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int zj = 6;//周几
int sum = 0;
string str;
int main()
{
int year = 2000;
int month = 1;
int day = 1;
for (int y = 2000; y <= 2020; y++){
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
months[2] = 29;
else months[2] = 28;
for (int m = 1; m <= 12; m++){
for (int d = 1; d <= months[m]; d++){
if (y == 2020 && m == 10 && d == 2) {
cout << sum << endl;
}
if (zj > 7)
zj %= 7;
if (zj == 1 || d == 1)
sum += 2;
else
sum += 1;
zj++;
}
}
}
system("pause");
return 0;
}