exercise_05_20.cpp 748 Bytes
Newer Older
1 2 3 4 5 6 7 8
#include <iostream>

int
main()
{
    for (int hypotenuse = 1; hypotenuse <= 500; ++hypotenuse) {
        for (int catheter1 = 1; catheter1 <= 340; ++catheter1) {
            for (int catheter2 = catheter1; catheter2 <= 483; ++catheter2) {
9 10 11 12 13 14
                if (catheter1 + catheter2 > hypotenuse) {
                if (catheter1 + hypotenuse > catheter2 ) {
                if (catheter2 + hypotenuse > catheter1) {
                    if (hypotenuse * hypotenuse == catheter1 * catheter1 + catheter2 * catheter2) {
                        std::cout << hypotenuse << ", " << catheter1 << ", " << catheter2 << std::endl;
                    }
15
                }
16 17
                }
                }       
18 19 20 21 22
            }
        }
    }
    return 0;
}