dazahui @ 2024-03-25 16:47:28
#include<bits/stdc++.h>
using namespace std;
int num=0;
int year1,year2,month1,month2,day1,day2,date1,date2;
int d[12]={31,28,31,30,31,30,31,31,30,31,30,31};
void judge(int year,int month,int day){
if((year%400==0||(year%4==0&&year%100!=0))&&month==1){
if(day>29) return;
}
else if(day>d[month-1]){
return;
}
else if(year==year1&&month<=month1&&day<day1) return;
else if(year==year2&&month>=month2&&day>day2) return;
else{
if(year/1000==day%10){
if((year/100)%10==day/10){
if(year%10==month/10){
if((year%100)/10==month%10){
num++;
printf("%4d%02d%02d\n",year,month,day);
}
}
}
}
}
}
int main()
{
cin>>date1>>date2;
year1=date1/10000,month1=(date1-year1*10000)/100,day1=date1%100;
year2=date2/10000,month2=(date2-year2*10000)/100,day2=date2%100;
for(int i=year1;i<=year2;i++)
{
for(int j=1;j<=12;j++)
{
for(int k=1;k<=31;k++)
judge(i,j,k);
}
}
cout<<num;
return 0;
}
Wa # 6,9,10,11