date




















P2:把年份抽出来倒过来,再插进去,判断时间段,合不合法,具体程序自己脑补。







var
        a,b,c,s11,s21,s12,s22,ans,s13,s23,d:longint;
        s1,s2:string;
function pd(b:longint):boolean;
var
        s11,s12,d:longint;
begin
        d:=b;
        s12:=b div 100;
        s22:=b mod 100;
        if (s12<=12)and(s12>=1) then
        begin
                if (s12=1)or(s12=3)or(s12=5)or(s12=7)or(s12=8)or(s12=10)or(s12=12) then
                begin
                        if (s22<=31)and(s22>=1) then exit(true);
                end;
                if (s12=4)or(s12=6)or(s12=9)or(s12=11) then
                begin
                        if (s22<=30)and(s22>=1) then exit(true);
                end;
                if (s12=2) then
                begin
                        if ((d mod 100=0)and(d mod 400=0))
                        or((d mod 4=0)and(d mod 100<>0)) then
                        begin
                                if (s22<=29)and(s22>=1) then exit(true);
                        end
                                else
                        begin
                                if (s22<=28)and(s22>=1) then exit(true);
                        end;
                end;
        end;
        exit(false);
end;
begin
        assign(input,'date.in');reset(input);
        assign(output,'date.out');rewrite(output);
        readln(s1);
        readln(s2);
        for a:=1 to 4 do
        begin
                s11:=s11*10+ord(s1[a])-48;
                s21:=s21*10+ord(s2[a])-48;
        end;
        s13:=s11;
        s23:=s21;
        for a:=5 to 8 do
        begin
                s12:=s12*10+ord(s1[a])-48;
                s22:=s22*10+ord(s2[a])-48;
        end;
        while s13<>0 do
        begin
                b:=b*10+(s13 mod 10);
                s13:=s13 div 10;
                c:=c*10+(s23 mod 10);
                s23:=s23 div 10;
        end;
        if (b=c) then
        begin
                if (b>=s12)and(b<=s22)and(pd(b)=true) then inc(ans);
        end
                else
        begin
                if (b>=s12)and(pd(b)=true) then inc(ans);
                if (c<=s22)and(pd(c)=true) then inc(ans);
        end;
        s22:=0;
        s12:=0;
        b:=0;
        c:=0;
        for a:=s11+1 to s21-1 do
        begin
                b:=a;
                d:=b;
                c:=0;
                while b<>0 do
                begin
                        c:=c*10+(b mod 10);
                        b:=b div 10;
                end;
                s12:=c div 100;
                s22:=c mod 100;
                if (s12<=12)and(s12>=1) then
                begin
                        if (s12=1)or(s12=3)or(s12=5)or(s12=7)or(s12=8)or(s12=10)or(s12=12) then
                        begin
                                if (s22<=31)and(s22>=1) then inc(ans);
                        end;
                        if (s12=4)or(s12=6)or(s12=9)or(s12=11) then
                        begin
                                if (s22<=30)and(s22>=1) then inc(ans);
                        end;
                        if (s12=2) then
                        begin
                                if ((d mod 100=0)and(d mod 400=0))
                                or((d mod 4=0)and(d mod 100<>0)) then
                                begin
                                        if (s22<=29)and(s22>=1) then inc(ans);
                                end
                                        else
                                begin
                                        if (s22<=28)and(s22>=1) then inc(ans);
                                end;
                        end;
                end;
        end;
        writeln(ans);
        close(input);
        close(output);
end.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值