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

TOP

@echo off
setlocal enabledelayedexpansion
set /p n=请输入需要求和的最大数:
for /l %%i in (1,1,%n%) do (
        set a=%%i
        set /a summ=summ+!a!
)
echo %summ%
pause>nul

TOP

@echo off
:n
set /a a+=1,b+=a
if "%a%"=="100" goto :end
goto :n
:end
echo 求和结束,结果是%b%
pause>nul

@echo off
:n
set /p m=请输入需要参与求和最大值:
set /a a+=1,b+=a
if "%a%"=="%m%" goto :end
goto :n
:end
echo 求和结束,结果是%b%
pause>nul

TOP

@echo off
:sc_start
set /a a+=1
set /a sum+=%a%
if not "%a%"=="100" goto sc_start
echo %sum%
pause

TOP

@echo off
setlocal enabledelayedexpansion
for /l %%i in (1 1 100) do (
    set /a summ=!summ!+%%i
)
echo %summ%&pause>nul

TOP

@echo off
set summ=0
for /l %%i in (1 1 100) do (
        set /a summ+=%%i
)
echo %summ%&pause>nul

TOP

@echo off
:sc_start
set /a a+=1
set /a c+=%a%
if %a%==100 (goto end) else (goto sc_start)
:end
echo %c%&pause>nul

TOP

@echo off
for /l %%i in (1 1 100) do (
        call set /a a=a+%%i
)
echo %a%
pause>nul

TOP

@echo off
for /l %%i in (1 1 100) do (
        call set /a num+=%%i
)
echo %num%&pause>Nul
exit

TOP

返回列表