Pathagorian triples
//
This is the program which shows all combinations, less than 500 making answer,
satisfying Pathagorian Theorum.
#
include<iostream>
#
include<conio.h>
using namespace std;
void main()
{
int p, q, r; //Here
we need three variables.
for (p = 1; p*p <= 500; ++p){
for (q = 1; q*q <= 500; ++q){
for (r = 1; r*r <= 500; ++r){
if ((p*p) + (q*q) == (r*r))
cout << p*p << " + " << q*q << " = " << r*r << endl;
}
}
}
_getch();
}
No comments:
Post a Comment