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. printf("n1:"); scanf("%d",&n1);
  10. printf("n2:"); scanf("%d",&n2);
  11. printf("n3:"); scanf("%d",&n3);
  12. deascend (&n1,&n2,&n3);
  13. printf("%d,%d,%d\n",n1,n2,n3);
  14. // your code goes here
  15. return 0;
  16. }
  17.  
  18. void deascend (int *x, int *y, int *z)
  19. {
  20. if (*x < *y){
  21. swap(x,y);
  22. }
  23. if (*x < *z){
  24. swap(x,z);
  25. }
  26. if (*y < *z){
  27. swap(y,z);
  28. }
  29. }
  30. void swap(int *a, int *b)
  31. {
  32. int temp;
  33. temp = *a;
  34. *a = *b;
  35. *b = temp;
  36. }
  37.  
Success #stdin #stdout 0s 5296KB
stdin
3
5
7
stdout
n1:n2:n3:7,5,3