fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int T[20] = {68, 29, 99, 2, 25, 16, 15, 24, 52, 21, 12, 91, 67, 5, 57, 4, 51, 17, 79, 71};
  5. int n = 20;
  6.  
  7.  
  8. for (int i = 1; i < n; i++) {
  9. int key = T[i];
  10. int j = i - 1;
  11.  
  12.  
  13. while (j >= 0 && T[j] > key) {
  14. T[j + 1] = T[j];
  15. j--;
  16. }
  17. T[j + 1] = key;
  18. }
  19.  
  20.  
  21. for (int i = 0; i < n; i++) {
  22. printf("%d", T[i]);
  23. if (i < n - 1) {
  24. printf(", ");
  25. }
  26. }
  27. printf("\n");
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
2, 4, 5, 12, 15, 16, 17, 21, 24, 25, 29, 51, 52, 57, 67, 68, 71, 79, 91, 99