二进制枚举子集问题
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int op = 0; op < 1 << n; op ++ )
{
for (int j = 0; j < n; j ++ )
{
if(op >> j & 1)
{
cout << a[j] <<" ";
}
}
cout << endl;
}
return 0;
}
?