第几天 - 蓝桥云课 (lanqiao.cn)
题目描述
题目分析
简单枚举(用k来记录经过的天数)
#include<bits/stdc++.h>
using namespace std;
bool is_ren(int n)
{
if(n % 400 == 0 || (n % 4 == 0 && n % 100 != 0))return true;
return false;
}
int m[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main()
{
int y = 2000;
if(is_ren(y))m[2] = 29;
int k = 0, flag = 0;
for(int i = 1; i <= 5; i ++)
{
for(int j = 1; j <= m[i]; j ++)
{
k ++;
if(i == 5 && j == 4)
{
cout << k;
flag = 1;
break;
}
}
if(flag)break;
}
return 0;
}