Hi, I have a problem in finding a code to work out all possible combinations of n int (digits) from m sets; the number of sets is given in input the number of digits in each set may vary from 1 to n. For example:
s[1] = 1, 2, 8, 5
s[2] = 6,
s[3] = 10, 3
should produce:
combo1: 1 6 10
combo2: 1 6 3
combo3: 2 6 10
combo4: 2 6 3
combo5: 8 6 10
combo6: 8 6 3
combo7: 5 6 10
combo8; 5 6 3
combo: 1 2 6 is incorrect because it contains two digits from the same set;
combo: 1 10 is incorrect because each combo must contain as many digits as the number of sets.
So far I started with
Then I got stuck. I'm new at C so I'd really appreciate some help. Tks!
s[1] = 1, 2, 8, 5
s[2] = 6,
s[3] = 10, 3
should produce:
combo1: 1 6 10
combo2: 1 6 3
combo3: 2 6 10
combo4: 2 6 3
combo5: 8 6 10
combo6: 8 6 3
combo7: 5 6 10
combo8; 5 6 3
combo: 1 2 6 is incorrect because it contains two digits from the same set;
combo: 1 10 is incorrect because each combo must contain as many digits as the number of sets.
So far I started with
Code:
struct node{ int id; struct succ} struct succ{ int val; struct succ *next; } struct node s[3]
Comment