#include <stdio.h>
void swap(int *x, int *y) {
int size=5;
for (int i = 0; i < size; i++) {
int w = *(x + i);
*(x + i) = *(y + i); //課題2の値渡しのは配列型
*(y + i) = w;
}
}
int main() {
int data1[5] = {1, 2, 3, 4, 5};
int data2[5] = {6, 7, 8, 9, 10};
swap(data1, data2);
for (int i = 0; i < 5; i++) {
}
for (int i = 0; i < 5; i++) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CnZvaWQgc3dhcChpbnQgKngsIGludCAqeSkgewogICAgaW50IHNpemU9NTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgc2l6ZTsgaSsrKSB7CiAgICAgICAgaW50IHcgPSAqKHggKyBpKTsgCiAgICAgICAgKih4ICsgaSkgPSAqKHkgKyBpKTsgICAgLy/oqrLpoYwy44Gu5YCk5rih44GX44Gu44Gv6YWN5YiX5Z6LCiAgICAgICAgKih5ICsgaSkgPSB3OyAgICAgCiAgICB9Cn0KCmludCBtYWluKCkgewogICAgaW50IGRhdGExWzVdID0gezEsIDIsIDMsIDQsIDV9OwogICAgaW50IGRhdGEyWzVdID0gezYsIDcsIDgsIDksIDEwfTsKCiAgICBzd2FwKGRhdGExLCBkYXRhMik7CgogICBwcmludGYoIuS6pOaPm+W+jOOBrumFjeWIlyBkYXRhMT0gIik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IDU7IGkrKykgewogICAgICAgIHByaW50ZigiJWQgIiwgZGF0YTFbaV0pOwogICAgfQoKCiAgICBwcmludGYoIuS6pOaPm+W+jOOBrumFjeWIlyBkYXRhMj0gIik7CiAgICBmb3IgKGludCBpID0gMDsgaSA8IDU7IGkrKykgewogICAgICAgIHByaW50ZigiJWQgIiwgZGF0YTJbaV0pOwogICAgfQoKICAgIHJldHVybiAwOwp9