#include <stdio.h>
void swap(int *a, int *b);
void sort(int *x, int *y);
int main(void) {
int x, y;
x = 20;
y = 10;
printf("並べ替え前: x = %d, y = %d\n", x
, y
);
sort(&x, &y);
printf("並べ替え後: x = %d, y = %d\n", x
, y
);
return 0;
}
void swap(int *a, int *b) {
int t = *a;
*a = *b;
*b = t;
}
void sort(int *x, int *y) {
if (*x < *y) {
swap(x, y);
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIHN3YXAoaW50ICphLCBpbnQgKmIpOwp2b2lkIHNvcnQoaW50ICp4LCBpbnQgKnkpOwoKaW50IG1haW4odm9pZCkgewoJaW50IHgsIHk7IAoJCgl4ID0gMjA7Cgl5ID0gMTA7CgkKCXByaW50Zigi5Lim44G55pu/44GI5YmNOiB4ID0gJWQsIHkgPSAlZFxuIiwgeCwgeSk7CgkKCXNvcnQoJngsICZ5KTsKCQoJcHJpbnRmKCLkuKbjgbnmm7/jgYjlvow6IHggPSAlZCwgeSA9ICVkXG4iLCB4LCB5KTsKCglyZXR1cm4gMDsKfQp2b2lkIHN3YXAoaW50ICphLCBpbnQgKmIpIHsgCglpbnQgdCA9ICphOyAKCSphID0gKmI7IAoJKmIgPSB0Owp9CQp2b2lkIHNvcnQoaW50ICp4LCBpbnQgKnkpIHsgCglpZiAoKnggPCAqeSkgeyAKCXN3YXAoeCwgeSk7IAoJCQoJfQp9