pesquisa

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

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.

#include <stdio.h>

int main() {
 float a, b, c, x; 
 scanf("%f %f %f", &a, &b, &c);
  if (a < b){ x = a; a = b; b = x; } 
  if (b < c){ x = b; b = c; c = x; } 
  if (a < b){ x = a; a = b; b = x; }
  if (a >= b + c) printf("NAO FORMA TRIANGULO\n");
     else
  if (a * a == b * b + c * c)
      printf("TRIANGULO RETANGULO\n");
     else 
  if (a * a > b * b + c * c)
printf("TRIANGULO OBTUSANGULO\n");
 else 
  if (a * a < b * b + c * c) printf("TRIANGULO ACUTANGULO\n");
  if (a == b && b == c) 
     printf("TRIANGULO EQUILATERO\n");
      else
  if (a == b || b == c) printf("TRIANGULO ISOSCELES\n");

    return 0;
}

Postar um comentário

0 Comentários