Problema: 1045
Enunciado:
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
Linguagem: C++
Solução:
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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | #include <iostream> using namespace std; int main() { double a, b, c, aux; cin >> a >> b >> c; if (a > b && a > c && c > b) { aux = b; b = c; c = aux; } if (b > a && b > c) { aux = a; a = b; b = aux; if (c > b) { aux = c; c = b; b = aux; } } if (c > a && c > b) { aux = a; a = c; c = aux; if (c > b) { aux = c; c = b; b = aux; } } if (a >= b + c) cout << "NAO FORMA TRIANGULO" << endl; else if (a * a == b * b + c * c) cout << "TRIANGULO RETANGULO" << endl; else if (a * a > b * b + c * c) cout << "TRIANGULO OBTUSANGULO" << endl; else cout << "TRIANGULO ACUTANGULO" << endl; if (a == b && b == c) cout << "TRIANGULO EQUILATERO" << endl; else if (a == b || a == c || b == c) cout << "TRIANGULO ISOSCELES" << endl; return 0; } |
Nenhum comentário:
Postar um comentário