@echo off &title 累加计算&color 1a&mode con cols=35 lines=10
set /p n=请输入从1累加到几的那个数:
set /a t=0
for /l %%i in (1,1,%n%) do (set /a t=t+%%i)
echo 累加结果是:%t%
pause >nul
@echo off
setlocal enabledelayedexpansion
set a=0
for /l %%i in (1,1,100) do set /a a=a+%%i
echo 1到100的数字之和为%a%
pause>nul
计算1到n
@echo off
echo 计算1+2+3+...+n=?
setlocal enabledelayedexpansion
set /p a=请输入n为几:
set b=0
for /l %%i in (1,1,%a%) do set /a b=b+%%i
echo 1到%a%的数字之和为%b%
pause>nul