Commit ffd088f9 authored by Michael's avatar Michael

michael.davityan:exercise_05_20v3

parent 071fb2a0
......@@ -3,32 +3,19 @@
int
main()
{
int count = 0;
for (int hypotenuse = 1; hypotenuse <= 500; ++hypotenuse) {
for (int catheter1 = 1; catheter1 <= 340; ++catheter1) {
for (int catheter2 = catheter1; catheter2 <= 483; ++catheter2) {
++count;
if (catheter1 + catheter2 > hypotenuse) {
if (hypotenuse * hypotenuse == catheter1 * catheter1 + catheter2 * catheter2) {
std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
}
}
}
}
}
for (int catheter1 = 1; catheter1 <= 340; ++catheter1) {
for (int catheter2 = catheter1; catheter2 <= 483; ++catheter2) {
for (int hypotenuse = 1; hypotenuse <= 500; ++hypotenuse) {
++count;
if (catheter1 + catheter2 < hypotenuse) {
if (hypotenuse * hypotenuse == catheter1 * catheter1 + catheter2 * catheter2) {
std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
}
}
for (int hypotenuse = 5; hypotenuse <= 500; ++hypotenuse) {
int variable = 2;
for (int catheter1 = hypotenuse - 1; catheter1 > 0; --catheter1) {
if (catheter1 + variable < hypotenuse) {
break;
}
for (int catheter2 = variable; catheter2 <= catheter1; ++catheter2) {
if (hypotenuse * hypotenuse == catheter1 * catheter1 + catheter2 * catheter2) {
std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
}
}
}
std::cout << "count = " << count << std::endl;
++variable;
}
}
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