本帖最后由 pcl_test 于 2015-4-21 22:20 编辑
- @echo off & setlocal enabledelayedexpansion
- set /p t=输入倒计时所需的时分秒(h:m:s)
- for /f "tokens=1-3 delims=:" %%a in ("%t%") do set "a=%%a" & set "b=%%b" & set "c=%%c"
- if %a:~,1% equ 0 if "%a:~1,1%" neq "" set "a=%a:~1%"
- if %b:~,1% equ 0 if "%b:~1,1%" neq "" set "b=%b:~1%"
- if %c:~,1% equ 0 if "%c:~1,1%" neq "" set "c=%c:~1%"
- set /a t=%a%*3600+%b%*60+%c%
- for /l %%i in (%t%,-1,1) do (
- cls
- set /a h=t/3600
- set /a m=t%%3600/60
- set /a s=t%%60
- set h=00!h!
- set m=00!m!
- set s=00!s!
- echo 倒计时[!h:~-2!:!m:~-2!:!s:~-2!]
- set /a t-=1
- ping 0 -n 2 >nul
- )
- exit
复制代码
|