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. for (int i = 1; i < n; i++) {
  8. int key = T[i];
  9. int j = i - 1;
  10.  
  11. while (j >= 0 && T[j] > key) {
  12. T[j + 1] = T[j];
  13. j--;
  14. }
  15. T[j + 1] = key;
  16. }
  17.  
  18. for (int i = 0; i < n; i++) {
  19. printf("%d", T[i]);
  20. if (i < n - 1) {
  21. printf(", ");
  22. }
  23. }
  24. printf("\n");
  25.  
  26. return 0;
  27. }
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