Bro_wang @ 2017-05-06 09:22:33
#include<cstdio>
#include<algorithm>
int day(int n)
{
int year=n/10000,mon=n%10000/100,day=n%100;
if(mon>12||day>30||mon==0||day==0)return 1;
if(mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12)
if(day<=31)
return 0;
if(mon==4||mon==6||mon==9||mon==11)
if(day<=30)
return 0;
if(mon==2)
{
if(year%4==0&&year%100!=0)
if(day<=29)
return 0;
else if(year%400==0)
if(day<=29)
return 0;
else{
if(day<=28)
return 0;
}
}
return 1;
}
int main()
{
int a1,a2,year1,year2,j,count=0;
scanf("%d%d",&a1,&a2);
year1=a1/10000;
year2=a2/10000;
for(int i=year1;i<=year2;i++)
{
j=i*10000+i%10*1000+i%100/10*100+i%1000/100*10+i/1000;
if(day(j)==0&&j>=a1&&j<=a2)
count++;
}
printf("%d\n",count);
return 0;
}
by Bro_wang @ 2017-05-06 10:00:50
问题已解决,谢谢