Advertisement
STANAANDREY

e1_3/4/2019

Apr 3rd, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  int v[1000],n,i,nr=0,k;
  7.  cout<<"n=";cin>>n;
  8.  for (i=0;i<n;i++)
  9.     cin>>v[i];
  10.  for (i=0;i<n;i++)
  11.      if (!v[i])
  12.      {
  13.          for (k=i;k<n-1;k++)
  14.          v[k]=v[k+1];
  15.          n--;
  16.          i--;
  17.          nr++;
  18.      }
  19. while (nr)
  20. {
  21.     v[n]=0;
  22.     n++;
  23.     nr--;
  24. }
  25. for (i=0;i<n;i++)
  26. cout<<"v["<<i<<"]="<<v[i]<<endl;
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement