批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程
[批处理文件精品]批处理版照片整理器[批处理文件精品]纯批处理备份&还原驱动在线第三方下载
返回列表 发帖
程序1
  1. @echo off
  2. SetLocal EnableDelayedExpansion
  3. set num=1 2 3 4
  4. for %%a in (%num%) do (
  5. set t_num=!num:%%a=!
  6. for %%b in (!t_num!) do (
  7. set tt_num=!t_num:%%b=!
  8. for %%c in (!tt_num!) do (
  9. echo %%a%%b%%c
  10. )
  11. )
  12. )
  13. pause
复制代码

TOP

程序4
  1. @echo off
  2. SetLocal EnableDelayedExpansion
  3. set /p str=Please enter(2014.7.28):
  4. for /f "delims=. tokens=1-3" %%a in ("%str%") do (
  5. call :jud %%a %%b %%c
  6. echo %%a.%%b.%%c is the !day!day for %%a
  7. pause>nul
  8. )
  9. :jud
  10. for %%i in (1 3 5 7 8 10 12) do set %%i=31
  11. for %%i in (4 6 9 11) do set %%i=30
  12. set /a jud=%1 %% 400
  13. if %jud%==0 (
  14. set 2=29
  15. ) else (
  16. set /a jud=%1 %% 4
  17. if !jud!==0 (
  18. set /a jud=%~1 %% 100
  19. if not !jud!==0 set 2=29
  20. ) else (set 2=28)
  21. )
  22. set /a month=%~2-1
  23. for /l %%i in (1 1 %month%) do (
  24. set /a day+=!%%i!
  25. )
  26. set /a day+=%3
复制代码
哎,不够熟练,竟然花了这么久...

TOP

程序8
  1. @echo off
  2. Setlocal enabledelayedexpansion
  3. for /l %%i in (1 1 9) do (
  4. set times=1
  5. for /l %%j in (1 1 %%i) do (
  6. set /a ans=%%i*%%j
  7. if not !times!==%%i (
  8. set /p =%%ix%%j=!ans!  <nul
  9. ) else (
  10. echo %%ix%%j=!ans!
  11. )
  12. set  /a times+=1
  13. )
  14. )
  15. pause>nul
复制代码

TOP

程序9
  1. @echo off
  2. SetLocal EnableDelayedExpansion
  3. for /l %%i in (1 1 8) do (
  4. for /l %%j in (1 1 8) do (
  5. set /a num=%%i+%%j,num%%=2
  6. if !num!==1 (set /p =■<nul) else (set /p =□<nul)
  7. )
  8. echo;
  9. )
  10. pause>nul
复制代码

TOP

程序11
  1. @echo off
  2. Setlocal enabledelayedexpansion
  3. set /a R0=1,R1=1
  4. set /p month=Please enter the month:
  5. for /l %%i in (2 1 %month%) do (
  6. set /a af=%%i-1,ag=%%i-2
  7. set /a R%%i=R!af! + R!ag!
  8. )
  9. echo !R%month%!
  10. pause>nul
复制代码
貌似超过45就不对了,如果要更多的话得专门写个无限数位加法了

TOP

程序12
  1. @echo off
  2. SetLocal EnableDelayedExpansion
  3. for /l %%i in (101,2,200) do (
  4. set num=%%i
  5. call :judge
  6. )
  7. pause>nul
  8. :judge
  9. set times=2
  10. for /l %%a in (1,1,3) do (
  11. set /a times+=%%i/times
  12. set /a times/=2
  13. )
  14. for /l %%j in (3,2,%times%) do (
  15. set /a value=%%i %% %%j
  16. if !value!==0 goto :eof
  17. )
  18. echo %num%
复制代码
用了牛顿迭代法开平方  感觉效率还可以

TOP

程序13
  1. @echo off
  2. Setlocal enabledelayedexpansion
  3. for /l %%a in (1 1 9) do (
  4. for /l %%b in (0 1 9) do (
  5. for /l %%c in (0 1 9) do (
  6. set /a jud=%%a*%%a*%%a+%%b*%%b*%%b+%%c*%%c*%%c
  7. if !jud!==%%a%%b%%c echo !jud!
  8. )
  9. )
  10. )
  11. pause>nul
复制代码

TOP

返回列表