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