fork download
  1. #include <stdio.h>
  2.  
  3. #define SIZE (10)
  4.  
  5. int main(void) {
  6.  
  7. int list[SIZE];
  8. int i, j, t;
  9.  
  10. printf("before\n");
  11. for (i = 0; i < SIZE; i++) printf("%d: %d\n", i + 1, list[i]);
  12.  
  13. for (i = 0; i < SIZE - 1; i++) {
  14. for (j = i + 1; j < SIZE; j++) {
  15. if (list[i] > list[j]) {
  16. t = list[i]; list[i] = list[j]; list[j] = t;
  17. }
  18. }
  19. }
  20.  
  21. printf("after\n");
  22. for (i = 0; i < SIZE; i++) printf("%d: %d\n", i + 1, list[i]);
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 2292KB
stdin
Standard input is empty
stdout
before
1: 134518744
2: 134514082
3: 1
4: -1081431132
5: -1081431124
6: -1217702171
7: -1215778608
8: 0
9: 134514011
10: -1216159756
after
1: -1217702171
2: -1216159756
3: -1215778608
4: -1081431132
5: -1081431124
6: 0
7: 1
8: 134514011
9: 134514082
10: 134518744