(1条消息) 闰年 判断的两种方式_兴趣源于专注的博客-CSDN博客_闰年的判断方法https://blog.csdn.net/qq_38178001/article/details/81126301
#include<iostream>
using namespace std;
int mon[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
bool is_leap(int y)
{
if(y%400==0 ||(y%4==0 &&y % 100 != 0))
return true;
else
return false;
}
int main()
{
int w =6;
int ans =0;
for(int y =2000;y<=2020;y++)
{
for(int m =1;m<=12;m++)
{
for(int d= 1;d<=mon[m]+((m == 2) ? is_leap(y) : 0);d++,w %=7)
{
ans++;
if(d==1||w==1)
ans++;
if(y==2020 && m == 10 && d == 1)
cout<<ans;
w++;
}
}
}
return 0;
}