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