Advertisement
Negru_Diana

ex6_tema_13.03.20

Mar 14th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int v[202];
  4. int main()
  5. {
  6. int n,x,i,cate=0,aux;
  7. cin>>n>>x;
  8. for(i=1;i<=n;i++)
  9. {
  10. cin>>v[i];
  11. if(v[i]==x)
  12. {
  13. cate++;
  14. }
  15. }
  16. aux=cate;
  17. for(i=n;i>=1;i--)
  18. {
  19. if(v[i]==x)
  20. {
  21. v[i+cate]=100;
  22. cate--;
  23. }
  24. v[i+cate]=v[i];
  25. }
  26. n=n+aux;
  27. for(i=1;i<=n;i++)
  28. {
  29. cout<<v[i]<<" ";
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement