date
来源:互联网 发布:ci框架数据库授权 编辑:程序博客网 时间:2024/06/17 12:42
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.
0 0
- date
- date
- date
- Date
- date
- date
- date
- date
- date
- date
- date
- date
- date
- date
- date
- date
- date
- date
- 位运算
- Android鬼点子-代码混淆
- 前端精选文摘:BFC 神奇背后的原理
- 安卓启动页
- 把n个物品分成m堆
- date
- Understand JVM:Java内存区域模型与内存溢出异常
- NOIP-2016-普及-题解
- 爱因斯坦传 - 笔记
- MyEclipse 导入Maven 项目编译没有classes 文件
- 最简单的 Linux 驱动程序
- 斐波那契数列的递归实现
- 2016-11-26
- ListView加普通的头、刷新、加载更多