Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main(int argc, char *argv[])
- {
- int a, b, c, hip, cat1, cat2;
- printf("Digite o primeiro valor: ");
- scanf("%d", &a);
- while (a==0) {
- printf("Insira outro valor diferente de 0: ");
- scanf("%d", &a);
- }
- printf("Digite o segundo valor: ");
- scanf("%d", &b);
- while (b==0) {
- printf("Insira outro valor diferente de 0: ");
- scanf("%d", &b);
- }
- printf("Digite o terceiro valor: ");
- scanf("%d", &c);
- while (c==0) {
- printf("Insira outro valor diferente de 0: ");
- scanf("%d", &c);
- }
- /* VERIFICA QUEM E A HIPOTENUSA */
- if (a>b && a>c && b > c) {
- hip=a;
- cat1=b;
- cat2=c;
- }
- else if (a>b && a>c && c > b) {
- hip=a;
- cat1=c;
- cat2=b;
- }
- else if (b>c && b>a && a > c) {
- hip=b;
- cat1=a;
- cat2=c;
- }
- else if (b>c && b>a && c > a) {
- hip=b;
- cat1=c;
- cat2=a;
- }
- else if (c>a && c>b && b > a) {
- hip=c;
- cat1=b;
- cat2=a;
- }
- else if (c>a && c>b && a > b) {
- hip=c;
- cat1=a;
- cat2=b;
- }
- /* ---------------------------- */
- printf("\nA hip eh %d, cat1 eh %d e cat2 eh %d", hip, cat1, cat2);
- /* LADOS IGUAIS NAO PODEM SER LADOS DE UM TRIANGULO RETANGULO */
- if (a==b || a==c || b==c) {
- printf ("\n\nEstes nao podem ser lados de um triangulo retangulo!\n\n");
- }
- /* ---------------------------- */
- if (hip*hip != cat1*cat1 + cat2*cat2) {
- printf("\n\nEstes nao podem ser lados de um triangulo retangulo!\n\n");
- }
- else {
- if (hip*hip == cat1*cat1 + cat2*cat2) {
- printf("\n\nEstes podem ser lados de um triangulo retangulo!\n\n");
- }
- }
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment