pesquisa

URI PROBLEMA 1045 - Tipos de Triângulos SOLUÇÃO EM PYTHON

URI Online Judge | 1045

Tipos de Triângulos

Adaptado por Neilor Tonin, URI  Brasil
Timelimit: 1
Leia 3 valores de ponto flutuante A, B e C e ordene-os em ordem decrescente, de modo que o lado A representa o maior dos 3 lados. A seguir, determine o tipo de triângulo que estes três lados formam, com base nos seguintes casos, sempre escrevendo uma mensagem adequada:
  • se A ≥ B+C, apresente a mensagem: NAO FORMA TRIANGULO
  • se A2 = B2 + C2, apresente a mensagem: TRIANGULO RETANGULO
  • se A2 > B2 + C2, apresente a mensagem: TRIANGULO OBTUSANGULO
  • se A2 < B2 + C2, apresente a mensagem: TRIANGULO ACUTANGULO
  • se os três lados forem iguais, apresente a mensagem: TRIANGULO EQUILATERO
  • se apenas dois dos lados forem iguais, apresente a mensagem: TRIANGULO ISOSCELES

Entrada

A entrada contem três valores de ponto flutuante de dupla precisão A (0 < A) , B (0 < B) e C (0 < C).

Saída

Imprima todas as classificações do triângulo especificado na entrada.


URI Online Judge | 1045

Triangle Types

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
Read 3 double numbers (A, B and C) representing the sides of a triangle and arrange them in decreasing order, so that the side A is the biggest of the three sides. Next, determine the type of triangle that they can make, based on the following cases always writing an appropriate message:
  • if A ≥ B + C, write the message: NAO FORMA TRIANGULO
  • if A2 = B2 + C2, write the message: TRIANGULO RETANGULO
  • if A2 > B2 + C2, write the message: TRIANGULO OBTUSANGULO
  • if A2 < B2 + C2, write the message: TRIANGULO ACUTANGULO
  • if the three sides are the same size, write the message: TRIANGULO EQUILATERO
  • if only two sides are the same and the third one is different, write the message: TRIANGULO ISOSCELES

Input

The input contains three double numbers, A (0 < A) , B (0 < B) and C (0 < C).

Output

Print all the classifications of the triangle presented in the input.




x = input().split()
a, b, c = x

n1 = float(1)
n2 = float(1)
n3 = float(1)
a = float(a)
b = float(b)
c = float(c)

if a >= b and a >= c:
    n1 = a
    if b >= c:
        n2 = b
        n3 = c
    else:
        n2 = c
        n3 = b
if b >= a and b >= c:
    n1 = b
    if a >= c:
        n2 = a
        n3 = c
    else:
        n2 = c
        n3 = a

if c >= a and c >= b:
    n1 = c
    if a >= b:
        n2 = a
        n3 = b
    else:
        n2 = b
        n3 = a             

if a == b and b == c:
    n1=a
    n2=b
    n3=c

a = n1
b = n2
c = n3

if a >= (b + c):
    print('NAO FORMA TRIANGULO')
else:
    if (a ** 2) == (b ** 2 + c ** 2):
        print('TRIANGULO RETANGULO')
    if (a ** 2) > (b ** 2 + c ** 2):
        print('TRIANGULO OBTUSANGULO')
    if (a ** 2) < (b ** 2 + c ** 2):
        print('TRIANGULO ACUTANGULO')
    if (a == b == c):
        print('TRIANGULO EQUILATERO')
    if a == b != c or b == c != a or a == c != b:
        print('TRIANGULO ISOSCELES')

Postar um comentário

0 Comentários