本帖最后由 QIAOXINGXING 于 2012-2-22 22:42 编辑
1 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | | | set /p a=输入一个四位数: | | for /l %%i in (0 1 3) do (set "b=!b! !a:~%%i,1!") | | echo !b! | | echo --------------- | | for /l %%i in (0 1 3) do (set "c= !a:~%%i,1!!c!") | | echo !c! | | echo --------------- | | for /l %%i in (0 1 3) do (echo !a:~%%i,1!) | | echo --------------- | | for /l %%i in (3 -1 0) do (echo !a:~%%i,1!) | | echo --------------- | | pause COPY |
2 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | set /p a=输入一个四位数: | | for /l %%i in (0 1 3) do ( | | set /a "b=!b!+!a:~%%i,1!" | | set "bb=!bb!+!a:~%%i,1!" | | ) | | set "bb=!bb:~1!" | | echo !bb!=!b! | | pauseCOPY |
3 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | set "n=0" | | :a | | set /a "n+=1" | | if not "!random!"=="2012" ( cls&echo 第 !n! 次 &goto :a) else (echo 行勒!! 共 !n! 次) | | pauseCOPY |
看了下前面的帖子: | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | | | :start | | for /l %%i in (1 1 1000) do ( | | set /a "n+=1" | | if !random!==2012 (echo ok & pause & exit) else (cls & echo 第 !n! 次) | | ) | | goto :start | | | | rem 纯 goto 效率确实很低,for的确强大。 | | | | COPY |
4 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | | | set "b=32768" | | set "c=0" | | set "n=0" | | | | :go1 | | set /a "n+=1" | | set /a "a=!random!%%!b!+!c!" | | if !a! lss 2012 (if !a! gtr !c! set "c=!a!") | | if !a! gtr 2012 (set /a "b1=!a!-!c!" & if !b1! lss !a! set /a "b=!a!-!c!") | | if !a! equ 2012 echo 共 !n! 次 & pause &exit | | echo !a! | | goto :go1COPY |
5 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | set /p a=输入年份: | | set /a "b1=!a!%%4" | | set /a "b2=!a!%%100" | | set /a "b3=!a!%%400" | | | | if "!b3!"=="0" (set "d=0" | | ) else ( | | if not "!b2!"=="0" (if "!b1!"=="0" set "d=0") | | ) | | if defined d (echo 是闰年) else (echo 不是闰年) | | | | pauseCOPY |
6 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | | | set "a=31 29 31 30 31 30 31 31 30 31 30 31" | | for /l %%i in (0 3 33) do ( | | set /a "m=%%i/3+1" | | set "n=!a:~%%i,2!" | | for /l %%a in (1 1 !n!) do ( | | echo 2012 年 !m! 月 %%a 日 | | ) | | ) | | | | pauseCOPY |
7 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | | | set "a=xls doc txt pdf gpg" | | for %%i in (!a!) do (>2012.%%i echo 2012 0) | | | | | | pauseCOPY |
8 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | set /p n=输入数字: | | | | set "aa=零 一 二 三 四 五 六 七 八 九" | | set "a=-1" | | for %%i in (!aa!) do ( | | set /a a+=1 | | set "b=%%i" | | call set "n=%%n:!a!=!b!%%" | | ) | | echo !n! | | pauseCOPY |
9 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | set "nn=0" | | :start | | set /p nn=输入位数不超过5的数字: | | set "n=" | | set "n4=" | | set "n3=" | | set "n2=" | | | | for /l %%i in (0 1 3) do (set "n= !nn:~%%i,1!!n!") | | | | | | set "aa=零 一 二 三 四 五 六 七 八 九" | | set "a=-1" | | for %%i in (!aa!) do ( | | set /a a+=1 | | set "b=%%i" | | call set "n=%%n:!a!=!b!%%" | | ) | | | | | | set "x=0" | | for %%i in (!n!) do (set /a x+=1 & set n!x!=%%i) | | | | if defined n4 (set n=!n4!千!n3!百!n2!十!n1! ) else ( | | if defined n3 (set n=!n3!百!n2!十!n1!) else ( | | if defined n2 (set n=!n2!十!n1!) else ( | | if defined n1 set n=!n1!))) | | | | | | set "n=!n:零百=零!" | | set "n=!n:零十=零!" | | set "n=!n:十零=十!" | | set "n=!n:零零=零!" | | set "n=!n:零零=零!" | | if "!n2!!n1!"=="零零" set "n=!n:百零=百!" | | if "!n3!!n2!!n1!"=="零零零" set "n=!n:千零=千!" | | echo !n! | | echo --------------------------------- | | goto :startCOPY |
10 | @echo off&setlocal enabledelayedexpansion&cd /d "%~dp0" | | | | set "a1=希望今年能少蛋疼。。。" | | set "a2=希望世界上所有人都好好的。。。" | | set "a3=谢谢!!!!!!" | | | | :go1 | | set /a "a+=1" | | call set "b=%%a!a!%%" | | | | for /l %%i in (0 1 20) do ( | | set /p=!b:~%%i,1!<nul | | ping 127.1 /n 1 >nul | | ) | | echo. | | if "!a!"=="3" pause >nul & exit | | goto :go1COPY |
|