fork download
  1. #include <stdio.h>
  2.  
  3. void swap(int *a, int *b);
  4. void sort(int *x, int *y);
  5.  
  6. int main(void) {
  7. int x=2;
  8. int y=3;
  9. sort(&x,&y);
  10. printf("降順:x=%d→y=%d\n",x,y);
  11. return 0;
  12. }
  13.  
  14. void swap(int *a, int *b){
  15. int w=*a;
  16. *a=*b;
  17. *b=w;
  18. }
  19.  
  20. void sort(int *x, int *y){
  21. if(*x<*y){
  22. swap(x,y);
  23. }
  24. }
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
降順:x=3→y=2