how can i cancel the repet in this program

How can i cancel the repeat in this program??
This Program is talking about Pythagoras Low

How can i cancel printing the same Numbers for more one time?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<iostream.h>
void main()
{

for(int x=1; x<=50;x++)
 {
	for(int y =1; y<=50;y++)
		{
		  for (int z =1;z<=50;z++)
			  {
				 if( x*x+y*y==z*z)
					cout<<"x: "<<x<<"  y: "<<y<<"  z: "<<z<<endl;
				}
		}
  }

}
1
2
3
4
if( x*x+y*y==z*z && x<y){ 
     cout<<"x: "<<x<<"  y: "<<y<<"  z: "<<z<<endl;
					  
 }
A bit more concise than mine - I was going to start the y loop at current value of x rather than 1.

Shouldn't it be x <=y ??
Thank you all for your help
the correct is to be the program like this:
#include<iostream.h>
void main()
{

for(int x=1; x<=50;x++)
{
for(int y =x; y<=50;y++)
{
for (int z =y;z<=50;z++)
{
if( x*x+y*y==z*z)
cout<<"x: "<<x<<" y: "<<y<<" z: "<<z<<endl;
}
}
}

Topic archived. No new replies allowed.