풀이과정
내적을 구하기 위해선 각 자리의 수를 곱하고 더해주면 된다.
#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;
}
'🍞 Problem Solving > Programmers' 카테고리의 다른 글
[프로그래머스][Level1] 소수 만들기 c++ (0) | 2022.09.03 |
---|---|
[프로그래머스][Level1] 로또의 최고 순위와 최저 순위 c++ (0) | 2022.09.03 |
[프로그래머스][Level1] x만큼 간격이 있는 n개의 숫자 c++ (0) | 2022.09.03 |
[프로그래머스][Level1] K번째수 c++ (0) | 2022.09.03 |
[프로그래머스][Level1] 행렬의 덧셈 c++ (0) | 2022.09.03 |