我正在制作一个代码,用于识别它的等边,等腰和斜角,但是我在等边部分编码时遇到了麻烦,因为这里的尺寸应该相等,这是我的代码。
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id="app"></div>
我的等边陈述是否正确?
答案 0 :(得分:0)
if
不支持a==b==c
此外,还没有任何AND
或OR
相反,您可以使用if %a%==%b% if %b%==%c% echo equilateral
您应首先检查等边位以防止&#34;早期等腰检测&#34;:
@echo off
echo enter the three sizes:
set /p "s1=size a: "
set /p "s2=size b: "
set /p "s3=size c: "
:: equilateral triangle
if "%s1%"=="%s2%" if "%s2%"=="%s3%" goto equilateral
REM if s1=s2 and s2=s3 then also s1=s3
:: Isosceles triangle
if "%s1%"=="%s2%" goto isosceles
if "%s1%"=="%s3%" goto isosceles
if "%s2%"=="%s3%" goto isosceles
:: scalene
echo the triangle is scalene
pause & goto :eof
:equilateral
echo the triangle is equilateral
pause & goto :eof
:scalene
echo the triangle is scalene
pause & goto :eof
:isosceles
echo the triangle is isosceles
pause & goto :eof
答案 1 :(得分:0)
您也可以使用这种更简单的方法:
@echo off
echo Enter the three sizes:
set /p "s1=size a: "
set /p "s2=size b: "
set /p "s3=size c: "
rem Next line means: s1=s2 AND s2=s3 (all sides are equal)
if "%s1%/%s2%" equ "%s2%/%s3%" goto equilateral
rem Next line means that all sides are different
if "%s1%" neq "%s2%" if "%s2%" neq "%s3%" if "%s3%" neq "%s1%" goto scalene
::isosceles
echo the triangle is isosceles
pause & goto :eof
:scalene
echo the triangle is scalene
pause & goto :eof
:equilateral
echo the triangle is equilateral
pause & goto :eof