fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin >> n;
  9. vector <int> v, v2;
  10. int x;
  11. while(cin>>x) v.push_back(x);
  12. int min = v[0];
  13. for(int q=1; q<n; q++) {
  14. if(v[q]<min) min = v[q];
  15. }
  16.  
  17. int min_counter = 0;
  18. for(int w=0; w<n; w++) {
  19. if(v[w] == min) min_counter++;
  20. }
  21.  
  22. for(int e=0; e<min_counter; e++) v2.push_back(min);
  23. for(int r=0; r<n; r++) {
  24. if(v[r]!=min) v2.push_back(v[r]);
  25. }
  26. for(int t=0; t<n; t++) cout << v2[t] << " ";
  27. return 0;
  28. }
Success #stdin #stdout 0s 4444KB
stdin
4 
3 0 0 5
stdout
0 0 3 5