三角形类型的写算法

问题描述 投票:0回答:1

我面临这样的问题:

编写一种算法,该算法读取代表三角形边的三个整数a, b, c。接下来,打印所表示的三角形的类型(斜角,等边,等腰)。假设代表了一个有效的三角形。

我想对我的算法可能出现的错误或我可以做些什么来改善其顺序性进行一些反馈:

step 1)  Start
step 2)  Declare int a,b,c
step 3)  Prompt a,b,c
step 4)  Read a,b,c
step 5)  If (a<>b and b<>c and c<>a) then
step 6)  Print "Scalene Triangle"
step 7)  Elseif((a=b and a != c) or (a=c and a!=b) or (b=c and b!=a))
step 8)  Print "Isoceles Triangle"
step 9)  Elseif ((a=b & b!=c ) or (a=c & c!=b) or (b=c & c!=a)) then
step 10) Print "Equilateral Triangle"
step 11) Endif
step 12) Stop
algorithm geometry logic pseudocode
1个回答
0
投票

您还将得到等边三角形作为等腰三角形,因此将其更改为:

  • ...
  • 如果(((a = b&b!= c)或(a = c&c!= b)或(b = c&c!= a))然后
  • 打印“斜角三角形”
  • ...
© www.soinside.com 2019 - 2024. All rights reserved.