指標_陣列合併相乘

 avatar
user_3763047219
c_cpp
a year ago
632 B
1
Indexable
Never
void array_mul(int* a, int* b, int size);


void array_mul(int* a, int* b, int size) {
    for (int i = 0; i < size; i++) {
        *a = *a * (*b);
        a++;
        b++;
    }
}

#include <stdio.h>


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_mul(data1, data2, size);
    for (int i = 0; i < size; i++) {
        printf("%d ", data1[i]);
    }
    printf("\n");
    return 0;
}