
- 帖子
- 4
- 积分
- 177
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2009-1-19
|
计算1到100
@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 |
|