list of pythagorean triples code example
Example 1: c Pythagorean triples
#include <stdio.h>
#include <stdlib.h>
int main() {
int a, b, c;
printf("TERNE PITAGORICHE!\n\nPrimo numero: ");
scanf("%d", &a);
printf("Secondo numero: ");
scanf("%d", &b);
printf("Terzo numero: ");
scanf("%d", &c);
if((a * a + b * b) == (c * c))
{
printf("E' una terna pitagorica!\n\n\n");
}
else
{
printf("Non e' una terna pitagorica!\n\n\n");
}
system("pause");
}
Example 2: pythagorean triplet
#include<bits/stdc++.h>
using namespace std;
bool check(int a,int b,int c){
int y,z;
int x = max(a,max(b,c));
if(x == a)
{
y=b;
z=c;
}
if(x == b)
{
y=a;
z=c;
}
if(x == c)
{
y=a;
z=b;
}
if((x*x)==(y*y) + (z*z)){
return 1;
}
else{
return 0;
}
}
int32_t main(){
int a,b,c;
cin>>a>>b>>c;
if(check(a,b,c)){
cout<<"Pythagoras triplet";
}
else{
cout<<"Not a Triplet";
}
return 0;
}