Advertisement
hurmawe

8.2

May 19th, 2022
711
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <vector>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. void odd_even(vector<int> &a,const int &lenght) {
  6.     int left = 0;
  7.     for (int i = 0; i < lenght; i++)
  8.     {
  9.         if (a[i] % 2 == 0)
  10.         {
  11.             swap(a[i], a[left]);
  12.             left++;
  13.         }  
  14.     }
  15. }
  16. int main()
  17. {
  18. vector<int> array = { 6, 9,66,785,632,569,56,654,2,0, 31,23,33};
  19. odd_even(array, array.size());
  20. for(int i=0;i<array.size();i++)
  21. cout<<array[i]<< " ";
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement