find all combinations of elements for the given number N (sum upto N)

Posted by webjockey on Stack Overflow See other posts from Stack Overflow or by webjockey
Published on 2010-04-05T20:06:14Z Indexed on 2010/04/05 20:13 UTC
Read the original article Hit count: 247

Filed under:
|
int array [] = {1,2,3,4,5,6,7,8,9}
N = 10

1,2,3,4 = 10
2,3,5 = 10
3,7 = 10
1,4,5 = 10
1,3,6 = 10
8,2 = 10
9,1 = 10
4,6 = 10
5,2,3 = 10
...

the function should return all combinations, the array may be unsorted

© Stack Overflow or respective owner

Related posts about algorithm

Related posts about homework