本帖最后由 Gin_Q 于 2019-12-16 10:35 编辑
正常代码:- @echo off & setlocal enabledelayedexpansion &rem by author Gan
- for /l %%a in (1900,1,2020) do (
- call :runnian %%a)
- pause & exit
- :runnian
- set m2=28
- set /a n=0
- set /a a=%1%%4,a1=%1%%100,a2=%1%%400
- if !a! equ 0 set n=1& if !a1! equ 0 set n=0
- if !a2! equ 0 set n=1
- if !n! equ 1 (set m2=29) else (set m2=28)
- echo %1 !m2! !n!
- goto :eof
复制代码 运行结果:
2000 29 1
2001 28 0
2002 28 0
2003 28 0
2004 29 1
2005 28 0
2006 28 0
2007 28 0
2008 29 1
2009 28 0
2010 28 0
2011 28 0
2012 29 1
2013 28 0
2014 28 0
2015 28 0
2016 29 1
2017 28 0
2018 28 0
2019 28 0
2020 29 1
请按任意键继续. . .
------------------------------------------------------------------------------分割线---------------------------------------------------------------------------------
少一个空格- @echo off & setlocal enabledelayedexpansion &rem by author Gan
- for /l %%a in (1900,1,2020) do (
- call :runnian %%a)
- pause & exit
- :runnian
- set m2=28
- set /a n=0
- set /a a=%1%%4,a1=%1%%100,a2=%1%%400
- if !a! equ 0 set n=1 & if !a1! equ 0 set n=0
- if !a2! equ 0 set n=1
- if !n! equ 1 (set m2=29) else (set m2=28)
- echo %1 !m2! !n!
- goto :eof
复制代码 :
运行结果:
2000 29 1
2001 28 0
2002 28 0
2003 28 0
2004 28 1
2005 28 0
2006 28 0
2007 28 0
2008 28 1
2009 28 0
2010 28 0
2011 28 0
2012 28 1
2013 28 0
2014 28 0
2015 28 0
2016 28 1
2017 28 0
2018 28 0
2019 28 0
2020 28 1
请按任意键继续. . . |