ValerianBenchea

Stergerea elementelor pare dintr-un vector

Dec 7th, 2021
899
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int n, i, j, v[101];
  7.     cin>>n;
  8.     for(i=1; i<=n; i++)
  9.         cin>>v[i];
  10.     for(i=1; i<=n; i++)
  11.         if(v[i]%2==0)
  12.         {
  13.             for(j=i; j<n; j++)
  14.                 v[j]=v[j+1];
  15.             n--; i--;
  16.         }
  17.     for(i=1; i<=n; i++)
  18.         cout<<v[i]<<" ";
  19.  
  20.     return 0;
  21. }
RAW Paste Data