[프로그래머스] 음양 더하기

Zoo Da·2021년 10월 8일
0

프로그래머스

목록 보기
5/10
post-thumbnail

링크

https://programmers.co.kr/learn/courses/30/lessons/76501

sol1) 구현

#include <string>
#include <vector>

using namespace std;

int solution(vector<int> absolutes, vector<bool> signs) {
    int answer = 0;
    for(int i = 0; i < absolutes.size(); i++){
        if(signs[i]) answer += absolutes[i];
        else answer -= absolutes[i];
    }
    return answer;
}

이것도 그냥 구현

profile
메모장 겸 블로그

0개의 댓글