129. 陣列合併

 avatar
user_6817964
c_cpp
2 years ago
599 B
0
Indexable
Never
void array_add(int* a, int* b, int size);
void array_add(int* a, int* b, int size) {
    for (int i = 0; i < 4; i++) {
        *a = *a + *b;
        a++;
        b++;
    }
}

int main() {

    int data1[4] = {};
    int data2[4] = {};
    int size = sizeof(data1) / sizeof(data1[0]);
    for (int i = 0; i < 4; i++) {
        scanf("%d", &data1[i]);
    }
    for (int i = 0; i < 4; i++) {
        scanf("%d", &data2[i]);
    }
    array_add(data1, data2, size);
    for (int i = 0; i < size; i++) {
        printf("%d ", data1[i]);
    }
    printf("\n");
    return 0;
}