Created
January 30, 2017 23:40
-
-
Save thomaswpp/640a920213968995497dfc7c34f535d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
int mdc(int n1, int n2){ | |
int resto = n1 % n2; | |
while(resto!=0){ | |
n1 = n2; | |
n2 = resto; | |
resto = n1 % n2; | |
} | |
return n2; | |
} | |
int is_pitagora(int n1, int n2, int n3){ | |
int result = pow(n1, 2) + pow(n2, 2); | |
if (result == pow(n3, 2)) | |
return 1; | |
return 0; | |
} | |
int main() | |
{ | |
int n1, n2, n3, mdc1, result; | |
while( scanf("%d %d %d", &n1, &n2, &n3) != EOF){ | |
result = is_pitagora(n1, n2, n3); | |
if (!result){ | |
printf("tripla\n"); | |
continue; | |
} | |
mdc1 = mdc(n1, n2); | |
if (mdc1 != 1) | |
printf("tripla pitagorica\n"); | |
else { | |
mdc1 = mdc(n1, n3); | |
if (mdc1 != 1) | |
printf("tripla pitagorica\n"); | |
else{ | |
mdc1 = mdc(n2, n3); | |
if (mdc1 != 1) | |
printf("tripla pitagorica\n"); | |
else { | |
printf("tripla pitagorica primitiva\n"); | |
} | |
} | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment