改成这样
@echo off
setlocal ENABLEDELAYEDEXPANSION
set/a sum=0
set/a ii=1
for /l %%i in (1,1,100) do (
set/a sum+=!ii!
set/a ii=10
echo !sum!
echo !ii!)
rem ii的值当然不会变,因为set/a ii=10每次循环都会把ii的值设成10
@echo off
setlocal enabledelayedexpansion
set /a sum=0
set /a ii=1
for /l %%i in (1,1,100) do (
echo ---------%%i--------
set /a sum+=!ii!
set /a ii=10
echo !sum!
echo !ii!
)
pause
变量用叹号括起来。