fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a, b, c, temp;
  5.  
  6. printf("3つの整数を入力してください(スペースで区切る): ");
  7. scanf("%d %d %d", &a, &b, &c);
  8.  
  9. // バブルソートのように並べ替え
  10. if (a > b) {
  11. temp = a;
  12. a = b;
  13. b = temp;
  14. }
  15. if (a > c) {
  16. temp = a;
  17. a = c;
  18. c = temp;
  19. }
  20. if (b > c) {
  21. temp = b;
  22. b = c;
  23. c = temp;
  24. }
  25.  
  26. printf("小さい順に並べた結果: %d %d %d\n", a, b, c);
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5312KB
stdin
3 8 1
stdout
3つの整数を入力してください(スペースで区切る): 小さい順に並べた結果: 1 3 8