50在这个时候出乎意料

时间:2019-03-31 02:23:36

标签: windows batch-file

我的代码在批处理文件中。

错误:

  

输入您的年龄:22
  目前有50个意外。

@echo off
set /p age = "enter your age:"
if %age% leq 50 ( 
    if %age% geq 20 (
        echo "You are %age% years old in the 21st century."
            ) else (
                echo "You are not in range."
) else (
    echo "You are not in range."
)
pause

1 个答案:

答案 0 :(得分:1)

这是脚本的更正版本。有两个问题

  • 如Squashman所述,请删除set命令中的空格
  • 括号中的不平衡

@echo off
set /p age="enter your age:"
if %age% leq 50 ( 
    if %age% geq 20 (
        echo "You are %age% years old in the 21st century."
    ) else (
        echo "You are not in range."
    ) 
) else (
    echo "You are not in range."
)
pause