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