#include <iostream>
#include <vector>
using namespace std;

//3 

void shiftzeroinend(vector<int> &arr)
{
   int n = arr.size();
   int start =0;
   int end = n-1;

   while(start<end)
   {
     if(arr[end] == 0)
     {
         end--;
     }
       
     if(arr[start] == 0)
     {
         swap(arr[start],arr[end]);
         end--;
     }
   
     start++;

   }


}

int main() {
    
   vector<int> arr = {3,5,0,1,2,0,8,0,11};

   shiftzeroinend(arr);

  for(auto itr : arr)
  {
     cout<<itr<<" ";       
  }

    
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: