1

我想问你一个问题。

我正在创建一个简单的程序来扫描数字(人们的成绩)并检查它们是否在某个范围内(例如,75% 到 90%),如果它们在某个范围内,请执行以下命令;这是代码。

(代码下方有更多文字)

@echo off
color a
title Happy Factor Decoder
echo Hello!
set /p eg="Exam Grade (RAW): "
set /p teg="TOTAL RAW Exam Grade (The highest score): "
echo Calculating
set /a m=%teg% - %eg%
echo You had %m% mistakes
echo Breaking down...
timeout /t 1 >nul
set /a bdf1=%eg% / 4
echo %bdf1%
set /a bdf2=%teg% / 4
echo %bdf2%
set /a bdf3=%m% / 4
echo %bdf3%
echo I BROKE IT DOWN YEAH :D
if %eg% == 4 goto happy
if %eg% == 3 goto kindahappy
if %eg% == 2 goto kindasad
if %eg% == 1 goto sad

:happy
echo Your father will be happy about this
pause

:kindahappy
echo Your father will be KINDA happy about this
pause

:kindasad
echo Your father will be KINDA sad about this
pause

:sad
echo Your father will be sad about this
pause

你看,我想要它做的是这个(在伪代码中)

IF BDF1 IS AT CERTAIN RANGE (80-90) GOTO HAPPY

有任何想法吗?

4

2 回答 2

3

number之间的一个只是,对吗???minmaxnumber>=max AND number<=min

IF %BDF1% GEQ 80 IF %BFD1% LEQ 90 GOTO :HAPPY
于 2013-07-25T11:06:31.357 回答
2

我不知道您的计算单位,但您可以检查从最低到最高的范围:

@ECHO OFF &SETLOCAL
REM some calculation here
IF %BDF1% leq 25 GOTO :sad
IF %BDF1% leq 50 GOTO :kindasad
IF %BDF1% leq 75 GOTO :kindahappy
IF %BDF1% leq 100 GOTO :happy
ECHO uups!
goto:eof

:sad
ECHO sad
goto:eof

:kindasad
ECHO kindased
goto:eof

:kindahappy
ECHO kindahappy
goto:eof

:happy
REM please enter your code here :)
于 2013-07-25T11:01:24.787 回答