fork(1) download
  1. #include <stdio.h>
  2.  
  3. void scanfall();
  4. void ascend();
  5. void swap();
  6. int x,y,z;
  7.  
  8. int main(void) {
  9.  
  10.  
  11. int a,b,c;
  12. printf("入力");
  13. scanfall(&x,&y,&z);
  14. printf("昇順");
  15. ascend(&x,&y,&z);
  16. return 0;
  17. }
  18.  
  19. void scanfall(int *x,int *y,int *z)
  20. {
  21. if(scanf("%d",x)==1)
  22. {
  23. printf("a=%d",*x);
  24. }
  25. if(scanf("%d",y)==1)
  26. {
  27. printf("b=%d, ",*y);
  28. }
  29. if(scanf("%d",z)==1)
  30. {
  31. printf("c=%d\n",*z);
  32. }
  33. }
  34.  
  35. void ascend(int *x,int *y,int *z)
  36. {
  37. if(*x<*y)
  38. {
  39. swap(&x,&y);
  40. }
  41. if(*x<*z)
  42. {
  43. swap(&x,&z);
  44. }
  45. if(*y<*z)
  46. {
  47. swap(&y,&z);
  48. }
  49. printf("a=%d,b=%d,c=%d",*x,*y,*z);
  50. }
  51.  
  52. void swap(int *x,int *y)
  53. {
  54. int temp;
  55. temp=*x;
  56. *x=*y;
  57. *y=temp;
  58. }
Success #stdin #stdout 0s 5276KB
stdin
1
3
2
stdout
入力a=1b=3, c=2
昇順a=3,b=2,c=1