my question is how can i make my program not to display any unique combination more that ones?

//*****f04.cpp*****
//Name:
//Date: 02 - 17 - 08


#include <iostream>
using namespace std;


int main ()
{
// #1
int a, b, c;
for (c = 1; c *c <= 100; c++)
{
for (a = 1; a <= 100; a++)
{
for (b = 1; b <= 100; b++)
{
if (c * c == a * a + b * b)
cout << c << ", " << a << " and " << b << endl;
}
}


}
Re: C++ Pythagorean Triple 80 80

How about for (b = 1; b <= a; b++) ?

Re: C++ Pythagorean Triple 80 80

Thanks alot! I didn't think that fix would be that easy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.