Advertisement
Josif_tepe

Untitled

Feb 16th, 2022
1,208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. int n;
  5.  
  6.  
  7. int main()
  8. {
  9.     cin >> n;
  10.     int power = 1;
  11.     for(int i = 1; i <= n; i++) {
  12.         power *= 2;
  13.     }
  14.     int pows_of_two = 0;
  15.     for(int i = 0; i < power; i++) {
  16.         pows_of_two = 1;
  17.         cout << "{";
  18.         for(int j = 0; j < n; j++) {
  19.             if(i & pows_of_two) {
  20.                 cout << j + 1 << " " ;
  21.             }
  22.             pows_of_two *= 2;
  23.         }
  24.         cout << "}" << endl;
  25.     }
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement