fork download
  1. #include <stdio.h>
  2.  
  3. void scanfall(int *x, int *y, int *z);
  4. void ascend(int *x, int *y, int *z);
  5. void swap(int *x, int *y);
  6.  
  7. int main(void)
  8. {
  9. int a, b, c;
  10. scanfall(&a, &b, &c);
  11. ascend(&a, &b, &c);
  12. printf("昇順: a=%d, b=%d, C=%d\n", a, b, c);
  13.  
  14. return 0;
  15. }
  16. void scanfall(int *x, int *y, int *z)
  17. {
  18. printf("3つの整数を入力してください:\n");
  19. scanf("%d %d %d", x, y, z);
  20. }
  21. void ascend(int *x, int *y, int *z)
  22. {
  23. if (*x > *y)
  24. swap(x, y);
  25. if (*x > *z)
  26. swap(x, z);
  27. if (*y > *z)
  28. swap(y, z);
  29. }
  30. void swap(int *x, int *y)
  31. {
  32. int temp = *x;
  33. *x = *y;
  34. *y = temp;
  35. }
Success #stdin #stdout 0s 5500KB
stdin
3 9 1
stdout
3つの整数を入力してください:
昇順: a=1, b=3, C=9