[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
  1. @echo off
  2. set var=0
  3. for /l %%a in (1,1,100) do (set /a var=var+%%a)
  4. echo 1+2+3+4+...+100=%var%
  5. pause>nul
复制代码

[ 本帖最后由 zsllq 于 2010-10-27 15:36 编辑 ]

TOP

{code}
@echo off
set a=0
set b=0
:a
echo +%a%=%b%
set /a a+=1
set /a b=%b%+%a%
if %a% gtr 100 (pause) else (goto a
exit
{/code}

TOP

@echo off
:abc
cls
set /a i = 1
set /p n=請輸入數字:
  1. @echo off
  2. :abc
  3. cls
  4. set /a i = 1
  5. set /p n=請輸入數字:
  6. if {%n%}=={} goto abc
  7. :acb
  8. set /a i+=1,j+=i
  9. if %i% neq %n% goto acb
  10. echo %j%
  11. pause
复制代码

if {%n%}=={} goto abc
:acb
set /a i+=1,j+=i
if %i% neq %n% goto acb
echo %j%
pause

TOP

@echo off
:abc
cls
set /a i = 1
set /p n=請輸入數字:
if {%n%}=={} goto abc
:acb
set /a i+=1,j+=i
if %i% neq %n% goto acb
echo %j%
pause

TOP

  1. @echo off
  2. set /a sum=0
  3. for /l %%a in (1 1 100) do (
  4. set/a sum+=%%a
  5. )
  6. echo %sum%
  7. set sum=
  8. pause>nul
复制代码

TOP

  1. ::任意数值的计算
  2. @echo off
  3. set str=0
  4. set /p var=input number
  5. for /l %%i in (1,1,%var%) do (
  6.     set /a str+=%%i
  7. )
  8. echo %str%
  9. pause>nul
复制代码

TOP

  1. ::从1加到100的
  2. @echo off
  3. set str=0
  4. for /l %%i in (1,1,100) do (
  5.     set /a str+=%%i
  6. )
  7. echo %str%
  8. pause>nul
复制代码

TOP

  1. @echo off&setlocal enabledelayedexpansion
  2. for /l %%i in (1,1,100) do set /a s+=%%i
  3. echo !s!
  4. pause
复制代码
  1. @echo off&setlocal enabledelayedexpansion
  2. set /p n=请输入数字:
  3. for /l %%i in (1,1,!n!) do set /a s+=%%i
  4. echo !b!
  5. pause
复制代码

TOP

  1. @echo off
  2. set t=0
  3. for /l %%a in (1 1 100) do (
  4. set/a t+=%%a
  5. )
  6. echo %t%
  7. pause
复制代码

TOP

  1. @echo off
  2. set n=101
  3. :loop
  4. set /a n=n-1
  5. set /a m+=n
  6. if %n% neq 0 goto loop
  7. echo %m%
  8. pause
复制代码

TOP

不用FOR算出来的

  1. @echo off
  2. SET N=0
  3. SET /P M=INPUT A NUMBER
  4. :START
  5. SET /A N+=1
  6. SET /A SUM+=%N%
  7. IF %N% EQU %M% (ECHO %SUM%) ELSE goto START
  8. PAUSE
复制代码

TOP

  1. @echo off
  2. set /a var=0
  3. for /l %%i in (1,1,100) do (
  4. set /a var+=%%i
  5. )
  6. echo %var%
  7. pause
复制代码

TOP

收藏了有空来学习一下

TOP

我也献丑

  1. rem 此为第二个问题答案
  2. @echo off
  3. set /p a=请输入数值
  4. for /l %%i in (1,1,%a%) do (
  5.     set /a n+=%%i
  6. )
  7. echo %n%
  8. pause
复制代码

TOP

这样行不?

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. for /l %%i in (1 1 100) do set /a b+=%%i
  4. echo !b!
  5. pause
复制代码

TOP

返回列表