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