Commit c43bb9d1 authored by Michael's avatar Michael

michael.davityan:exercise_05_20v8

parent ff67e922
......@@ -9,13 +9,12 @@ main()
const int hypotenuseSquare = hypotenuse * hypotenuse;
for (int catheter1 = 3; catheter1 < hypotenuse - 1; ++catheter1) {
const int catheter1Square = catheter1 * catheter1;
const int CATHETER_LIMIT = std::max(catheter1, hypotenuse-catheter1+1);
for (int catheter2 = hypotenuse - 1; catheter2 > CATHETER_LIMIT; --catheter2) {
const int catheterLimit = std::max(catheter1, hypotenuse - catheter1 + 1);
for (int catheter2 = hypotenuse - 1; catheter2 > catheterLimit; --catheter2) {
const int catheter2Square = catheter2 * catheter2;
if (hypotenuseSquare == catheter1Square + catheter2Square) {
std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
}
++count;
}
}
}
......
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