[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
第一到第六题。
  1. @echo off
  2. set /p no=请输入想要操作的数  (1-9) :
  3. set /a no1=%no%*%no%
  4. set /a no2=%no%*%no%*%no%
  5. for /l %%i in (1 1 %no%) do (set /a no3+=%%i)
  6. set no4=1
  7. for /l %%i in (1 1 %no%) do (set /a no4*=%%i)
  8. for /l %%i in (1 1 %no%) do (set /a no5+=%%i*%%i)
  9. for /l %%i in (1 1 %no%) do (set /a no6+=%%i*%%i*%%i)
  10. echo %no%的平方为:%no1%
  11. echo %no%的立方为:%no2%
  12. echo 1到%no%的和为:%no3%
  13. echo 1到%no%的积为:%no4%
  14. echo 1到%no%的平方和为:%no5%
  15. echo 1到%no%的立方和为:%no6%
  16. pause>nul
复制代码
nothing's gonna change
and I've never changed

TOP

求点评~~~
1-6:
  1. @echo off&setlocal enabledelayedexpansion
  2. set /p "p=请输入要操作的数(1-9):"
  3. set j=1
  4. for /l %%a in (1,1,%p%) do (
  5. set /a p2=%%a*%%a
  6. set /a p3=%%a*%%a*%%a
  7. set /a h=!h!+%%a
  8. set /a j=%%a*!j!
  9. set /a ph=!ph!+!p2!
  10. set /a lh=!lh!+!p3!
  11. )
  12. echo %p%的平方:%p2%
  13. echo %p%的立方:%p3%
  14. echo 从1到%p%的和:%h%
  15. echo 从1到%p%的积:%j%
  16. echo 从1到%p%的平方和:%ph%
  17. echo 从1到%p%的立方和:%lh%
复制代码
数列:
  1. @echo off&setlocal enabledelayedexpansion
  2. set /p "p=请输入要操作的数(1-9):"
  3. for /l %%a in (1,1,%p%) do (
  4. for /l %%i in (1,1,%p%) do (
  5. set /a n+=1
  6. set /p=!n! <nul
  7. )
  8. echo;
  9. )
复制代码
螺纹:
  1. @echo off&setlocal enabledelayedexpansion
  2. set /p p=输入:
  3. set /a x=1,num=%p%,sum=%p%*%p%
  4. set yuns=--
  5. for /l %%y in (1,1,%num%) do (set/a n+=1,y+=1&set _%x%_%%y=!n!)
  6. :lp
  7. set /a num-=1
  8. for /l %%a in (1,1,%num%) do (set/a n+=1,x=!x!%yuns%1&set _!x!_!y!=!n!)
  9. set yuns=-%yuns%
  10. for /l %%a in (1,1,%num%) do (set/a n+=1,y=!y!%yuns%1,ys+=1&set _!x!_!y!=!n!)
  11. if not %n% equ %sum% goto :lp
  12. for /l %%a in (1,1,%p%) do (
  13. for /l %%b in (1,1,%p%) do (
  14. set /p=!_%%a_%%b! <nul
  15. )
  16. echo;
  17. )
复制代码

TOP

  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. set /a length=20 & set /a width=23
  4. set /a max=length*width
  5. call :len %max% maxlength
  6. set /a i=1 & set /a j=1 & set /a idelta=0 & set /a jdelta=1 & set /a imax=length & set /a jmax=width & set /a count=0 & set /a imin=2 & set /a jmin=1
  7. :setvalue
  8.     set /a count+=1
  9.     call :loop temp %count% %maxlength%
  10.     set matrix[%i%][%j%]=%temp%
  11.     if "%idelta%,%jdelta%"=="0,1" ( if %j%==%jmax% ( set /a idelta=1 & set /a jdelta=0 & set /a jmax-=1 ))
  12.     if "%idelta%,%jdelta%"=="1,0" ( if %i%==%imax% ( set /a idelta=0 & set /a jdelta=-1 & set /a imax-=1))
  13.     if "%idelta%,%jdelta%"=="0,-1" ( if %j%==%jmin% ( set /a idelta=-1 & set /a jdelta=0 & set /a jmin+=1))
  14.     if "%idelta%,%jdelta%"=="-1,0" ( if %i%==%imin% ( set /a idelta=0 & set /a jdelta=1 & set /a imin+=1))
  15.     set /a i+=idelta & set /a j+=jdelta
  16.     if %count% lss %max% (
  17.         goto:setvalue
  18.     )
  19. for /l %%i in (1,1,%length%) do (
  20.     set str=!matrix[%%i][1]!
  21.     for /l %%j in (2,1,%width%) do ( set "str=!str! !matrix[%%i][%%j]!" )
  22.     echo !str!
  23. )
  24. exit
  25. :loop
  26.    set number=         %2
  27.    set %1=!number:~-%3!
  28. goto :eof
  29. :len
  30.    set Tempstrs=%~1 & Set Tempnum=0
  31.    :下一位
  32.       set Tempstr=!Tempstrs:~%Tempnum%,1!
  33.       if defined Tempstr ( set /a Tempnum+=1 & goto :下一位 )
  34.       set /a %~2=%Tempnum%-1
  35. goto :eof
复制代码

TOP

返回列表