Commit b37723ec authored by Michael's avatar Michael

michael.davityan:exercise_05_20v4

parent 1f20fbb1
#include <iostream>
#include <cmath>
int
main()
{
const int LENGTH_LIMIT = 500;
for (int hypotenuse = 5; hypotenuse <= LENGTH_LIMIT; ++hypotenuse) {
for (int catheter1 = hypotenuse - 2; catheter1 < hypotenuse; ++catheter1) {
for (int catheter2 = 2; catheter2 < catheter1; ++catheter2) {
if (hypotenuse * hypotenuse == catheter1 * catheter1 + catheter2 * catheter2) {
std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
const int SIDE_LENGTH_LIMIT = 500;
for (int hypotenuse = 5; hypotenuse <= SIDE_LENGTH_LIMIT; ++hypotenuse) {
for (int catheter1 = 3; catheter1 < hypotenuse - 1; ++catheter1) {
for (int catheter2 = hypotenuse - 1; catheter2 > catheter1; --catheter2) {
if (catheter1 + catheter2 < hypotenuse + 1) {
break;
}
}
}
}
/* for (int hypotenuse = 5; hypotenuse <= 500; ++hypotenuse) {
int firstValue = 2;
for (int catheter1 = hypotenuse - 1; catheter1 > 0; --catheter1) {
if (catheter1 + firstValue < hypotenuse) {
break;
}
for (int catheter2 = firstValue; catheter2 < catheter1; ++catheter2) {
if (hypotenuse * hypotenuse == catheter1 * catheter1 + catheter2 * catheter2) {
if (pow(hypotenuse, 2) == pow(catheter1, 2) + pow(catheter2, 2)) {
std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
}
}
++firstValue;
}
} */
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment