Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int n;
- int main()
- {
- cin >> n;
- int power = 1;
- for(int i = 1; i <= n; i++) {
- power *= 2;
- }
- int pows_of_two = 0;
- for(int i = 0; i < power; i++) {
- pows_of_two = 1;
- cout << "{";
- for(int j = 0; j < n; j++) {
- if(i & pows_of_two) {
- cout << j + 1 << " " ;
- }
- pows_of_two *= 2;
- }
- cout << "}" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement