Advertisement
STANAANDREY

Remove_duplicate(extra space)

Jul 3rd, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. const int n=10;
  7. int v[]={1,2,2,3,3,4,4,4,5,6};
  8. int v2[100],j=0;
  9.  
  10. for (int i=0;i<n-1;i++)
  11. if (v[i]!=v[i+1])
  12. {
  13.     v2[j]=v[i];
  14.     j++;
  15. }
  16. v2[j]=v[n-1];
  17. for (int i=0;i<=j;i++)
  18.     cout<<v2[i]<<' ';
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement