Advertisement
Josif_tepe

Untitled

Mar 30th, 2022
871
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. #include <cstring>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.  
  9.     int n = 3;
  10.    
  11.     for(int i = 0; i < (1 << n); i++) {
  12.         for(int j = 0; j < n; j++) {
  13.             if(i & (1 << j)) {
  14.                 cout << j + 1 << " ";
  15.             }
  16.         }
  17.         cout << endl;
  18.     }
  19.  
  20.     return 0;
  21. }
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement