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