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