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

쉬운 목차

문제


연산

1. 번호 입력

2. 부호 결정 후 결과 추가

암호

#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++){
        int value = absolutes(i);
        bool sign = signs(i);        
        if(sign){
            answer+=value;
        }
        else{
           answer-=value; 
        }
    }
    
    return answer;
}