Possible Duplicate:
How to find all possible subsets of a given array?
How can all ways of selection of items be generated efficiently using C++?
For example, if there are there items A, B and C.
[A,B,C] => [A], [B], [C], [A,B], [B,C], [A,C], [A, B, C]
For that input set:
Output:
Demo : http://ideone.com/2Wxbi
Now it’s your turn to improve and generalize this approach, and find it’s limitations.