fork download
  1. #include <stdio.h>
  2.  
  3. void scanfull(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. int a, b, c;
  9. scanfull(&a, &b, &c);
  10. printf("入力: a=%d, b=%d, c=%d\n", a, b, c);
  11. ascend(&a, &b, &c);
  12. printf("昇順: a=%d, b=%d, c=%d\n", a, b, c);
  13. return 0;
  14. }
  15.  
  16. void scanfull(int *x, int *y, int *z){
  17. scanf("%d",&*x);
  18. scanf("%d",&*y);
  19. scanf("%d",&*z);
  20. }
  21.  
  22. void ascend(int *x, int *y, int *z){
  23. if(*y < *x){
  24. swap(x, y);
  25. }
  26. if(*z < *x){
  27. swap(x, z);
  28. }
  29. if(*z < *y){
  30. swap(y, z);
  31. }
  32. }
  33.  
  34. void swap(int *x, int *y){
  35. int w;
  36. w = *x;
  37. *x = *y;
  38. *y = w;
  39. }
  40.  
Success #stdin #stdout 0s 5288KB
stdin
3
2
1
stdout
入力: a=3, b=2, c=1
昇順: a=1, b=2, c=3