avoid duplicates in groups of number 1-7

i some how manage to make a code but still it shows duplicates.

for example 123
321
456
654

i want to make it work to avoid duplicates like possible groupings can someone help me regarding this topic thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>

int x, y, z;

main()
{
	for(x=1; x<=7;x++)
	{
		for(y=2; y<=7;y++)
		{
			for(z=3; z<=7;z++)
			{
				if(x != y & x != z & y != z & y !=x & z!= x & z != y)
				{
				
				printf("%d%d%d\n", x, y, z);
		  		}
			}	
		}	
	}

}
closed account (48T7M4Gy)
if(x != y || x != z || y != z|| y !=x||z!= x||z != y)

Get's rid of 123 and 321 so your logic whether its && or || is lacking.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>

int x, y, z;

main()
{
   for(x=1; x<=7;x++)
	{
		for(y=x; y<=7;y++)
		{
			for(z=y; z<=7;z++)
			{
				if(x != y && x != z && y != z && y !=x && z!= x && z != y)
				{
				
				printf("%d%d%d\n", x, y, z);
		  		}
			}	
		}	
	}

}
123
124
125
126
127
134
135
136
137
145
146
147
156
157
167
234
235
236
237
245
246
247
256
257
267
345
346
347
356
357
367
456
457
467
567
Last edited on
thank you for this. sorry im just starting learning C, thank you for this learned something new
Topic archived. No new replies allowed.