4
作者:
一酱饼子
,
2024-09-05 20:23:59
,
所有人可见
,
阅读 3
#include<iostream>
using namespace std;
string st,ed;
int sti,edi;
int months[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
bool isRunNian(int x)
{
return (x % 4 == 0 && x % 100 != 0) || x % 400 == 0;
}
int main()
{
cin >> st >> ed;
long long res = 0;
bool NotExsit = false;
for(int i = 0;i < st.size();i ++)
{
if(st[i] >= '0' && st[i] <= '9') sti = sti * 10 + st[i] - '0';
if(ed[i] >= '0' && ed[i] <= '9') edi = edi * 10 + ed[i] - '0';
}
for(int i = sti;i <= edi;i ++)
{
months[2] = 28;
int year = i / 10000;
int month = i % 10000 / 100;
int day = i % 100;
if(isRunNian(year)) months[2] = 29;
if(day <= months[month] && day >= 1 && month >= 1 && month <= 12) res ++;
}
cout << res << endl;
return 0;
}