Advertisement
Josif_tepe

Untitled

Oct 24th, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. using namespace std;
  5. typedef long long ll;
  6. int n;
  7. int arr[101];
  8. void rec(int i, vector<int> v) {
  9.     if(i == n) {
  10.         for(int j = 0; j < v.size(); j++) {
  11.             cout << v[j] << " ";
  12.         }
  13.         cout << endl;
  14.         return;
  15.     }
  16.     rec(i + 1, v); // ne go zimame i-tiot element
  17.    
  18.     vector<int> tmp = v;
  19.     tmp.push_back(arr[i]);
  20.     rec(i + 1, tmp);
  21.    
  22. }
  23. int main()
  24. {
  25.  
  26.     cin >> n;
  27.    
  28.     for(int i = 0; i < n; i++) {
  29.         cin >> arr[i];
  30.     }
  31.     vector<int> v;
  32.     rec(0, v);
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement