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