gpt4 book ai didi

math - 在 CMD 中为所有方程获取缺少操作数错误?

转载 作者:行者123 更新时间:2023-12-03 08:28:39 27 4
gpt4 key购买 nike

:Calcu
color 4D
mode 250
echo -----------------------------------------------------------------------------------------------
echo Welcome To The Calculator
echo -----------------------------------------------------------------------------------------------
echo "------>You have the option do Adding Subtraction Multiplication and Division just type<-------"
echo "------>the question and it will give you the answer for each of the type<-------"
echo -----------------------------------------------------------------------------------------------
echo Type 1 For Addition, 2 For Subtraction, 3 For Multiplication And 4 For Division:
@set /p Type=
IF /I %Type%==1 (
echo Addition
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Sum = %First% + %Second%
echo %First% + %Second% = %Sum%
)

IF /I %Type%==2 (
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Sub = %First% - %Second%
echo %First% - %Second% = %Sub%
)
IF /I %Type%==3 (
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Multi = %First% * %Second%
echo %First% X %Second% = %Multi%
)
IF /I %Type%==4 (
@set /p First = Enter First Number:
@set /p Second = Enter Second Number:
@set /a Div = %First% / %Second%
echo %First% ÷ %Second% = %Div%
)
IF /I %Type%=>5 (
echo Not a Valid Number
)
pause
goto Calcu

谁能告诉我为什么我得到一个缺少操作数的错误
我试图让这个计算器工作,但它不工作
数学运算在另一个代码块中工作,但不是在这里

最佳答案

设置变量时,不要在 = 周围使用空格,否则空格将成为变量名称或值的一部分。

set /p First = Enter First Number:
echo %first%
echo %first %
set /p "First=Enter First Number: "
echo %first%

至于 delayed Expansion , JosefZ 提到:
if A==A (
set /p First = Enter First Number:
echo %first% - !first!
echo %first % - !first !
set /p "First=Enter First Number: "
echo %first% - !first!
)

关于math - 在 CMD 中为所有方程获取缺少操作数错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32660947/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com