BUPT-homework/semester1/pset9/4-vector.c

26 lines
352 B
C

#include <stdio.h>
int main(void) {
int n;
scanf("%d", &n);
int vec1[n];
int vec2[n];
for (int i = 0; i < 2; i++) {
for (int j = 0; j < n; j++) {
if (i == 0)
scanf("%d", &vec1[j]);
else
scanf("%d", &vec2[j]);
}
}
int sum = 0;
for (int i = 0; i < n; i++) {
sum += vec1[i] * vec2[i];
}
printf("%d\n", sum);
return 0;
}