分析:用两个数组装数据,再将对应位置的数据相乘、累加即可。
#include<iostream>
using std::cout;
using std::cin;
//using std::endl;
//#include<array>
//using std::array;
//#include<iomanip>
//using std::fixed;
//using std::setprecision;
int main()
{
int n = 0;
cin >> n;
int a[1000], b[1000];
for (int i = 0; i < n; ++i)
{
cin >> a[i];
}
for (int i = 0; i < n; ++i)
{
cin >> b[i];
}
int result = 0;
for (int i = 0; i < n; ++i)
{
result += (a[i] * b[i]);
}
cout << result;
}