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