fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a, b, c, temp;
  5.  
  6. // 入力の読み込み
  7. printf("3つの整数を入力してください(例: 3 1 2): ");
  8. scanf("%d %d %d", &a, &b, &c);
  9.  
  10. // バブルソート的に並べ替え(手動で3つの値をソート)
  11. if (a > b) {
  12. temp = a;
  13. a = b;
  14. b = temp;
  15. }
  16. if (a > c) {
  17. temp = a;
  18. a = c;
  19. c = temp;
  20. }
  21. if (b > c) {
  22. temp = b;
  23. b = c;
  24. c = temp;
  25. }
  26.  
  27. // 結果を出力
  28. printf("昇順に並べた結果: %d %d %d\n", a, b, c);
  29.  
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0.01s 5280KB
stdin
59
stdout
3つの整数を入力してください(例: 3 1 2): 昇順に並べた結果: -1816822448 59 32767