I have this code which generates power set of an array of size 4 (number is just example, less combinations to write...).
#define ARRAY_SIZE 4
unsigned int i,
I used this answer to make following code:
Basically you need to print nCr
sequences for all r
#include
#include
using namespace std;
//This generates all nCr sequences
void display(const std::vector & v,
std::vector& comb,
int offset, int k) {
if (k == 0) {
std::cout<<"{";
for(auto &x:comb)
std::cout< v,comb;
for (int i = 0; i < n; ++i)
v.push_back(i+1);
for (int i = 1; i <= n; ++i)
display(v,comb,0, i);
return 0;
}
See here