Date le misure dei tre lati di un triangolo, decidere se si tratta di un triangolo equilatero, isoscele, …
Un percorso per individuare la categoria di appartenenza potrebbe essere
Decsioni indipendenti
1 2 3 4 5 |
If(a = b) And (a = c) Then TextWindow.WriteLine("EQUILATERO") Else TextWindow.WriteLine("Non è equilatero") EndIf |
1 2 3 4 5 |
If(a = b) Or (a = c) Or (b = c) Then TextWindow.WriteLine("ISOSCELE") Else TextWindow.WriteLine("Non è isoscele") EndIf |
1 2 3 4 5 |
If(a <> b) And (a <> c) And (b <> c) Then TextWindow.WriteLine("SCALENO") Else TextWindow.WriteLine("Non è scaleno") EndIf |
1 2 3 4 5 6 7 8 9 |
a2=a*a b2=b*b c2=c*c If(a2 = b2+c2) Or (b2 = a2+c2) Or (c2 = a2+b2) Then TextWindow.WriteLine("RETTANGOLO") Else TextWindow.WriteLine("Non è rettangolo") EndIf |
Decisioni collegate
1 2 3 4 5 6 7 |
If(a = b) And (a = c) Then TextWindow.WriteLine("EQUILATERO") ElseIf(a = b) Or (a = c) Or (b = c) Then TextWindow.WriteLine("ISOSCELE") Else TextWindow.WriteLine("SCALENO") EndIf |
Continua…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
TextWindow.Write("a=") a=TextWindow.ReadNumber() TextWindow.Write("b=") b=TextWindow.ReadNumber() TextWindow.Write("c=") c=TextWindow.ReadNumber() if(a+b < c) Or (a+c < b) Or (b+c < a) Then TextWindow.WriteLine("--- Non è un triangolo! ---") Else If(a = b) And (a = c) Then TextWindow.WriteLine("EQUILATERO") Else If(a = b) Or (a = c) Or (b = c) Then TextWindow.WriteLine("ISOSCELE") Else TextWindow.WriteLine("SCALENO") EndIf a2=a*a b2=b*b c2=c*c If(a2 = b2+c2) Or (b2 = a2+c2) Or (c2 = a2+b2) Then TextWindow.WriteLine("Triangolo rettangolo") ElseIf(a2 > b2+c2) Or (b2 > a2+c2) Or (c2 > a2+b2) Then TextWindow.WriteLine("Triangolo ottusangolo") Else TextWindow.WriteLine("Triangolo acutangolo") EndIf |