Repetition in loops

Hi,

I'm trying to write a code that will provide all possible combination of the number 13, using three digits. (at this stage everything works fine) .
But now i would like to remove repetitions, ex. 10+2+1 = 13 and 1+2+10= 13 i wud like to remove this kind of repetition , but i'm not sure how?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// sort algorithm example
#include <iostream>
#include <cmath>
using namespace std;



void main(void) {
	for (int i = 0; i<=13 ; i++){
		for(int b = 0; b <= 13; b++){
			for (int c=0; c<=13;c++){
				
				if ((i + b + c) == 13){
					cout << i << " " << b << " " << c << endl;}
			}}}

	system("pause");

}



Thanks
Last edited on
1
2
3
for (int i = 0; i<=13 ; i++){
	for(int b = i; b <= 13; b++){
		for (int c=b; c<=13;c++){
Thanks , it works :D
Topic archived. No new replies allowed.