我想要一个非常简单的批处理文件,允许我一起添加数字 我在想像
@echo off
Set /a number1=enter a number
Set /a number2=enter your second number
set /a sum1==%number1%+%number2%
echo your fist numer was %number1% and your second number was %number2%
echo When you add them both together you get %sum1% hmmmmmmmmmmmmmm
pause
答案 0 :(得分:1)
使用/ p提示输入
@echo off
Set /p number1=Enter a number:
Set /p number2=Enter your second number:
set /a sum1=%number1%+%number2%
echo your fist numer was %number1% and your second number was %number2%
echo When you add them both together you get %sum1% hmmmmmmmmmmmmmm
pause
答案 1 :(得分:1)
@echo off
Set /p numbera=Enter a number:
Set /p numberb=Enter a second number:
set /a sum=numbera+numberb
echo your fist numer was %numbera% and your second number was %numberb%
echo When you add them both together you get %sum% hmmmmmmmmmmmmmm
pause>nul
我认为这种方法看起来更干净。使用set / p作为输入,并使用= not ==来设置变量。这是一个例子。
set x=2
set y=3
set /a z=x+y+2
echo z is equal to %z%
pause>nul
输出应为z is equal to 7
。如您所见,x+y+2
看起来更像是数学而不是%x%+%y%+2
。
如果我错过了我的解释,评论,我会解决它。如果这有帮助,请标记为正确的答案,以便我知道我回答了这个问题。
; )玩得开心!!