我已经为三角形识别编写了一些代码,但是无法为直角三角形编写代码。
#!/bin/sh
echo "enter the value of a"
read a
echo "enter the value of b"
read b
echo "enter the value of c"
read c
if [ $c = $a = $b ]
then
echo "Its a equilateral triangle"
fi
if [ $c != $a != $b ]
then
echo "Its a Triangle"
fi
答案 0 :(得分:2)
if [ ($a*$a) + ($b*$b) = ($c*$c) ]
then
echo "right angle in triangle"
fi
答案 1 :(得分:0)
使用bash:
#!/bin/bash
echo "enter the value of a"
read a
echo "enter the value of b"
read b
echo "enter the value of c"
read c
if ((c == a && c == b )); then
echo "Its a equilateral triangle"
exit 0
fi
if ((c != a || c != b )); then
echo "Its a Triangle"
fi