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