Pythagorean theorem

I'm writing a program that calculates the number of Pythagorean triangles in which no sida is larger than then 500
Specification
 Calculate and print the number of Pythagorean triangles
 Print version of the triangles Whose hypotenuses IS 100, 200, 300, 400 and 500th
 No page in the triangle exceed 500
 Each page should be an integer!
 It's not allowed to use float at anytime
 Assume triangles with pairs of identically catheter, for example, [A = 3, b = 4, c = 5] and [a = 4, b = 3, c = 5], is the same triangle.

 
I don't know how to start.  
closed account (48T7M4Gy)
x*x + y*y == z*z && x <= 500 && y <= 500 etc && y <= x
Should I use for loops then?
So my code looks like this right now but the output don't show anything.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using namespace std;
int main ()
{
    int c, b, a;
    
    while(a*a+b*b==c*c)
    {
    
    for (a=1; a<=500; a++)
    {
        for (b=a; b<=500; b++)
        {
            for (c=b; c<=500; c++)
            {
                
            }
        }
    }
    
    
    }
    
    return 0;
    
    
}
Hello markusfurst,

but the output don't show anything.

That is because you never output anything. Also you have three for loops that do nothing but count. Add cout >> something at line 15 or line 19 or line 22 to show some output.

Hope that helps,

Andy
closed account (48T7M4Gy)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>

int main()
{
    std::cout << "a\tb\tc\n";
    
    for (int a = 1; a <= 500; a++)
    {
        for (int b = a; b <= 500; b++)
        {
            for (int c = b; c <= 500; c++)
            {
                if ( /*   a*a etc   */ )
                {
                    std::cout << /*   display results   */ <<  '\n';
                }
            }
        }
    }
    
    return 0;
}
Last edited on
Topic archived. No new replies allowed.