#include<iostream> #include<vector> using namespace std; vector<vector<int> > result; int cnt; void solution(vector<int> nums) { int num=1; cnt = (1 << nums.size()); for(int i = 0; i < cnt; i++) { vector<int> item; for(int j = 0; j < nums.size(); j++) { if(i & (1 << j)) { item.push_back(nums[j]); } } result.push_back(item); } } int main() { vector<int> nums; nums.push_back(1); nums.push_back(2); nums.push_back(3); solution(nums); for(int i = 0; i < cnt; i++) { if(result[i].size() == 0) { cout<<"[]"; } for(int j = 0; j < result[i].size(); j++) { cout<<"["<<result[i][j]<<"]"; } cout<<endl; } return 0; }