forever_dreams @ 2017-09-02 10:16:12
#include<cstdio>
using namespace std;
int k[15]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int a,b,c,p[10];
int f()
{
int t,i=4;
t=a;
while(t!=0)
{
p[i]=t%10;
t/=10;
i--;
}
p[5]=b/10;
p[6]=b%10;
p[7]=c/10;
p[8]=c%10;
for(i=1;i<=4;++i)
if(p[i]!=p[9-i])
return 0;
return 1;
}
int main()
{
int x,y,z,s=0;
scanf("%4d%2d%2d",&a,&b,&c);
scanf("%4d%2d%2d",&x,&y,&z);
while(1)
{
s+=f();
if(a==x&&b==y&&c==z)
break;
c++;
if((a%4==0&&a%100!=0)||a%400==0)
k[2]=29;
else
k[2]=28;
if(c>k[b])
{
c=1;
b++;
}
if(b>13)
{
b=1;
a++;
}
}
printf("%d",s);
return 0;
}
by 览遍千秋 @ 2017-09-02 10:25:09
闰年没有特判
by 爱因斯7 @ 2017-09-02 13:10:37
恩
by forever_dreams @ 2017-09-02 13:13:34
可是我加了特判啊
if((a%4==0&&a%100!=0)||a%400==0) k[2]=29;
else
k[2]=28;