Advertisement
Josif_tepe

Untitled

Jun 12th, 2022
801
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <cstring>
  4. #include <algorithm>
  5. #include <stack>
  6. using namespace std;
  7. int arr[5];
  8. void rec(int i, vector<int> v) {
  9.     if(i == 3) {
  10.         for(int k = 0; k < v.size(); k++) {
  11.             cout << v[k] << " ";
  12.         }
  13.         cout << endl;
  14.         return;
  15.     }
  16.     rec(i + 1, v);
  17.     vector<int> tmp_v = v;
  18.     tmp_v.push_back(arr[i]);
  19.     rec(i + 1, tmp_v);
  20. }
  21. int main() {
  22.     vector<int> v;
  23.     arr[0] = 1;
  24.     arr[1] = 2;
  25.     arr[2] = 3;
  26.    
  27.     rec(0, v);
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement