Advertisement
Josif_tepe

Untitled

Feb 16th, 2022
1,193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 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.     for(int bit = 0; bit < (1 << n); bit++) {
  11.         cout << "{";
  12.         for(int i = 0; i < n; i++) {
  13.             if(bit & (1 << i)) {
  14.                 cout << i + 1 << " ";
  15.             }
  16.         }
  17.         cout << "}" << endl;
  18.     }
  19.     return 0;
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement