fork(1) download
  1. #include <stdio.h>
  2.  
  3. void deascend(int *x, int *y, int *z);
  4. void swap(int *a, int *b);
  5.  
  6. int main(void)
  7. {
  8. int n1,n2,n3;
  9.  
  10. printf("n1:"); scanf("%d",&n1);
  11. printf("n2:"); scanf("%d",&n2);
  12. printf("n3:"); scanf("%d",&n3);
  13.  
  14. deascend(&n1,&n2,&n3);
  15.  
  16. printf("%d, %d, %d\n", n1, n2, n3);
  17.  
  18. return 0;
  19. }
  20.  
  21. void deascend(int *x, int *y, int *z)
  22. {
  23. if((*x>=*y)&&(*x>=*z))
  24. {
  25. if(*z>=*y)
  26. swap(&z,&y);
  27. }
  28. if((*y>=*x)&&(*y>=*z)) swap(&x,&y);
  29. {
  30. if(*z>=*x)
  31. swap(&z,&x);
  32. }
  33. if((*z>=*x)&&(*z>=*y)) swap(&x,&z);
  34. {
  35. if(*z>=*y)
  36. swap(&z,&y);
  37. }
  38.  
  39. }
  40.  
  41. void swap(int *a,int *b)
  42. {
  43. int w;
  44.  
  45. w=*a;
  46. *a=*b;
  47. *b=w;
  48. }
Success #stdin #stdout 0s 5516KB
stdin
1 3 5
stdout
n1:n2:n3:1, 3, 5