标题: [数值计算] 批处理加法运算中遇到的无法执行 [打印本页]
作者: 夜未央 时间: 2019-1-21 21:01 标题: 批处理加法运算中遇到的无法执行
- @echo on
-
- set /a a = 1
- set /a b= 2
- set /a t = 2
- echo a=%a%
- echo b=%b%
- echo t=%t%
-
- (for /l %%i in (1,1,%t%) do (
-
- echo %%i%
- set entry%%i%
- entry%%i% = %a% + %b% +1
- echo entry%%i%
- echo %entry%%i%%
- pause
- ))
- echo %entry1%
- echo %entry2%
- echo 1
- pause
复制代码
想要输出加法运算后的两个数值,但实际执行中
F:\>(
echo 1
set entry1
entry1ab +1
echo entry1
echo
pause
)
1
作者: Batcher 时间: 2019-1-21 22:01
等号左右两边不要有空格
for循环内部使用控制变量%%i而不是%%i%- @echo off
- setlocal enabledelayedexpansion
- set a=1
- set b=2
- set t=2
- echo a=%a%
- echo b=%b%
- echo t=%t%
-
- for /l %%i in (1,1,%t%) do (
- echo %%i
- set entry%%i=0
- set /a entry%%i=a+b+1
- echo entry%%i
- echo !entry%%i!
- pause
- )
- echo %entry1%
- echo %entry2%
- pause
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |