michael8111 当前离线
一级士官
@ echo offset /a num=1+2+3+4+...+100echo %a%pauseCOPY
TOP
lscorpion 当前离线
列兵
@echo off //关闭回显set /a sum=0 //一开始总和为0for %%i in(1,1,100) do (set /a sum++) //循环100次对sum进行累加call echo 总的结果是:%sum% //输出最终结果pause //暂停exitCOPY
chenfei 当前离线
xjc080304 当前离线
poxi 当前离线
二级士官
@echo off:1set con=0set ds=0set /p end=请输入要加到的值::---------循环首----------:startset /a con+=1set /a ds=%ds%+%con%::---------循环尾----------if %con%==%end% (echo 答案是:%ds%) else (goto start)goto 1COPY
solid 当前离线
三级士官
@echo offSETLOCAL ENABLEDELAYEDEXPANSIONfor /l %%a in ( 0 1 100 ) do ( set ji=%%a set /a jia+=!ji!)echo !jia!pauseCOPY
rogue_1983 当前离线
六级士官
原帖由 yaohaixu 于 2008-5-5 22:45 发表 不用FOR也是一样的可以的 @echo off set /a a=0,c=0 :start set /a a+=1,c=c+a if "%a%"=="100" goto end goto start :end echo. %c% pause
fish 当前离线
中尉
@echo offset /p n=请输入:set /a sum=(1+%n%)*%n%/2echo 1加到%n%的和是%sum%pauseCOPY
qq506657335 当前离线
四级士官
@echo off&setlocal enabledelayedexpansionset a=0for /l %%i in (1 1 100) do ( set c=%%i set /a a=!a!+!c! cls&@echo !a!)pauseCOPY
@echo offsetlocal enabledelayedexpansionfor /l %%i in (1 1 100) do set /a b+=%%iecho !b!pauseCOPY
lvsehuaxue 当前离线
rem 此为第二个问题答案@echo offset /p a=请输入数值for /l %%i in (1,1,%a%) do ( set /a n+=%%i)echo %n%pauseCOPY
win 当前离线
piedcity 当前离线
@echo offset /a var=0for /l %%i in (1,1,100) do (set /a var+=%%i)echo %var%pauseCOPY
gaoyi445267987 当前离线
@echo offSET N=0SET /P M=INPUT A NUMBER:STARTSET /A N+=1SET /A SUM+=%N%IF %N% EQU %M% (ECHO %SUM%) ELSE goto STARTPAUSECOPY
@echo offset n=101:loopset /a n=n-1set /a m+=nif %n% neq 0 goto loopecho %m%pauseCOPY