fork download
  1. #include <stdio.h>
  2.  
  3. void sort(int *x, int n){
  4. int i, j, tmp;
  5.  
  6. for (i = 1; i < n; i++) {
  7. for (j = 0; j < n - i; j++) {
  8. if (x[j] > x[j+1]) {
  9. tmp = x[j];
  10. x[j] = x[j+1];
  11. x[j+1] = tmp;
  12. }
  13. }
  14. }
  15. }
  16.  
  17. int main(){
  18. int x[] = {3,4,2,5,1};
  19.  
  20. sort(x, 5);
  21.  
  22. for(int i=0;i<5;i++){
  23. printf("%d ", x[i]);
  24. }
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
1 2 3 4 5