#include <stdio.h>
void swap(int *x, int *y);
int main(void) {
int data1[5] = {1,2,3,4,5};
int data2[5] = {6,7,8,9,10};
//int *x;
//int *y;
//x = data1;
//y = data2;
for(int i=0;i<5;i++){
swap(&data1[i], &data2[i]);
printf("配列data1[%d]:%d\n", i
,data1
[i
]); printf("配列data2[%d]:%d\n", i
,data2
[i
]); }
return 0;
}
void swap(int *x, int *y) {
int w;
w = *x;
*x = *y;
*y = w;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp2b2lkIHN3YXAoaW50ICp4LCBpbnQgKnkpOwoKaW50IG1haW4odm9pZCkgewoJaW50IGRhdGExWzVdID0gezEsMiwzLDQsNX07CglpbnQgZGF0YTJbNV0gPSB7Niw3LDgsOSwxMH07CgkKCS8vaW50ICp4OwoJLy9pbnQgKnk7CgkKCS8veCA9IGRhdGExOwoJLy95ID0gZGF0YTI7CgkKCWZvcihpbnQgaT0wO2k8NTtpKyspewoJCXN3YXAoJmRhdGExW2ldLCAmZGF0YTJbaV0pOwoJCQoJCXByaW50Zigi6YWN5YiXZGF0YTFbJWRdOiVkXG4iLCBpLGRhdGExW2ldKTsKCQlwcmludGYoIumFjeWIl2RhdGEyWyVkXTolZFxuIiwgaSxkYXRhMltpXSk7Cgl9CgkKCXJldHVybiAwOwp9Cgp2b2lkIHN3YXAoaW50ICp4LCBpbnQgKnkpIHsKCWludCB3OwoJdyA9ICp4OwoJKnggPSAqeTsKCSp5ID0gdzsKfQo=