2014-11-28 2 views
-1

삼각형 식별을위한 코드를 작성했지만 직각 삼각형을 작성할 수 없습니다. 함께쉘 스크립팅에 사각형을 넣는 방법

#!/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

참조. 그것이 사각형이 들어오는 곳입니다 – fsimkovic

답변

0

: 오른쪽 삼각형이^2 + B^2 = C^2 피타고라스를 사용하여 결정될 수있다 @anubhava

#!/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 

http://wiki.bash-hackers.org/syntax/arith_expr

2
if [ ($a*$a) + ($b*$b) = ($c*$c) ] 
then 
echo "right angle in triangle" 
fi 
+0

사용자가 가장 긴면을 마지막으로 입력하는 경우에만 ... –

+0

sh 스크립트에서 작동하지 않습니다. 메타 문자 *를 읽을 수 없습니다. – VoraciousReader

관련 문제