fork 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){
  24. swap(x,y);
  25. }
  26. if (*x<*z){
  27. swap(x,z);
  28. }
  29. if (*y<*z){
  30. swap(y,z);
  31. }
  32. }
  33.  
  34. void swap(int *a, int *b)
  35. {
  36. int temp = *a;
  37. *a = *b;
  38. *b = temp;
  39. }
Success #stdin #stdout 0s 5320KB
stdin
2 8 4
stdout
n1:n2:n3:8,4,2