Advertisement
achulkov2

Untitled

Sep 18th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     for (int mask = 0; mask < (1 << n); ++mask) {
  9.         cout << "subset: ";
  10.         for (int i = 0; i < n; ++i) {
  11.             if (mask & (1 << i)) {
  12.                 cout << i << " ";
  13.             }
  14.         }
  15.         cout << "\n";
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement