SHARE
TWEET

Untitled

a guest Jan 25th, 2015 189 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. vector<int> copyElements(vector<int> array, vector<int> array2, int n, int i)
  7. {
  8.  
  9.     if (n == array.size())
  10.     {
  11.         return array;
  12.     }
  13.     else
  14.     {
  15.         if (array[n] % 2 == 0)
  16.         {
  17.             array2[i] = array[n];
  18.             i++;
  19.         }
  20.  
  21.         return copyElements(array, array2, n + 1, i);
  22.     }
  23.  
  24. }
  25.  
  26. int main()
  27. {
  28.     //initialize the two vectors
  29.     vector<int> array;
  30.     for(int i = 0; i < 8; i++)
  31.     {
  32.         array.push_back(i);
  33.     }
  34.     vector<int> array2;
  35.  
  36.     copyElements(array, array2, 0, 0);
  37.  
  38.     return 0;
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top