fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n;
  7. cin >> n;
  8. int *ptr = new int [n];
  9.  
  10. for(int i=0; i<n; i++)
  11. cin >> (*(ptr+i));
  12.  
  13. int *buf = new int;
  14.  
  15. for(int i = 0; i < n - 1; i++)
  16. {
  17. for(int j = 0; j < n - i - 1; j++)
  18. if(*(ptr+j) > *(ptr+j + 1))
  19. {
  20. *buf = *(ptr+j);
  21. *(ptr+j) = *(ptr+j+1);
  22. *(ptr+j+1) = *buf;
  23.  
  24. }
  25. }
  26.  
  27. for(int i=0; i<n; i++)
  28. cout << (*(ptr+i));
  29.  
  30. delete []ptr;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 4124KB
stdin
3
4
3
6
stdout
346