fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4.  
  5. int T[20] = {66, 27, 97, 0, 23, 14, 13, 22, 50, 19, 10, 89, 65, 3, 55, 2, 49, 15, 77, 69};
  6. int N = 20;
  7. int work;
  8.  
  9.  
  10. for (int i = 0; i < N - 1; i++) {
  11. for (int j = i + 1; j < N; j++) {
  12.  
  13. if (T[i] > T[j]) {
  14.  
  15. work = T[i];
  16. T[i] = T[j];
  17. T[j] = work;
  18. }
  19. }
  20. }
  21.  
  22.  
  23. printf("ソート後のデータ: ");
  24. for (int k = 0; k < N; k++) {
  25. printf("%d", T[k]);
  26. if (k < N - 1) {
  27. printf(", ");
  28. }
  29. }
  30. printf("\n");
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 5320KB
stdin
2 33 21 
stdout
ソート後のデータ: 0, 2, 3, 10, 13, 14, 15, 19, 22, 23, 27, 49, 50, 55, 65, 66, 69, 77, 89, 97