Algorithm/C++ - 프로그래머스

프로그래머스 - 내적 C++

ㅇㅇ잉 2021. 2. 18. 21:30

vector원소 하나씩 곱해주면 된다.

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <string>
#include <vector>
 
using namespace std;
 
int solution(vector<int> a, vector<int> b) {
    int answer = 0;
    
    for(int i=0;i<a.size();i++){
        answer+=a[i]*b[i];
    }
    return answer;
}
cs