Commit 9ddce7f7 authored by Michael's avatar Michael

michael.davityan:exercise_05_20v7

parent b37723ec
#include <iostream>
#include <cmath>
int
main()
......@@ -7,11 +6,8 @@ main()
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;
}
if (pow(hypotenuse, 2) == pow(catheter1, 2) + pow(catheter2, 2)) {
for (int catheter2 = hypotenuse - 1; (catheter2 > catheter1) && (catheter1 + catheter2 > hypotenuse + 1); --catheter2) {
if (hypotenuse * hypotenuse == catheter1 * catheter1 + catheter2 * catheter2) {
std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
}
}
......
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