Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This algorithm was crated by Lucas Pereira Torres de Araujo
- #Lista 2 - FUP's Class - 2016.1
- #Item P
- ALGORITMO
- DECLARE
- a, b, c, d1, d2, d3, d4, d5, d6 NUMERICO
- hip, cateto1, cateto2 NUMERICO
- x1, relacao1, graus1, x2, relacao2, graus2 NUMERICO
- ESCREVA "Digite os três lados do triângulo: "
- LEIA a, b, c
- d1 ← |(b - c)|
- d2 ← |(a - c)|
- d3 ← |(a - b)|
- d4 ← (b + c)
- d5 ← (a + c)
- d6 ← (a + b)
- #1.1 - Verificar a existência do triangulo
- SE d1 < a E a < d4 E d2 < b E b < d5 E d3 < c E c < d6 ENTÃO
- ESCREVA "Existe um triângulo cujo os lados são:", a, b, c
- #1.2 - Verificar a hipotenusa e os catetos, se é retângulo
- SE a > b E a > c ENTÃO
- hip ← a
- cateto1 ← b
- cateto2 ← c
- SENÃO
- SE b > a E b > c ENTÃO
- hip ← b
- cateto1 ← a
- cateto2 ← c
- SENÃO
- SE c > a E c > b ENTÃO
- hip ← c
- cateto1 ← a
- cateto2 ← b
- #1.2 - FIM
- #1.3 - Verificar se obedece ao teorema de Pitágoras, se é retângulo.
- SE hip² = (cateto1² + cateto2²) ENTÃO
- ESCREVA "É um triângulo retângulo."
- #Arco seno é o inverso do Seno
- relacao1 ← cateto1/hip
- x1 ← Arcoseno(relacao1)
- graus1 ← (x*180)/PI
- relacao2 ← cateto2/hip
- x2 ← Arcoseno(relacao2)
- graus2 ← (x*180)/PI
- ESCREVA "Os ângulos são: 90°,", graus1, graus2
- SENÃO
- ESCREVA "Não é um triângulo retângulo."
- #1.3 - FIM
- SENÃO
- ESCREVA "Não existe um triângulo cujos lados sejam:", a, b, c
- #1.1 - FIM
- FIM_ALGORITMO.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement