프로그래머스 - 성격 유형 검사하기

2022. 9. 3. 20:17코딩 공부 연습

반응형
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int alpha[105];

string solution(vector<string> survey, vector<int> choices) {
    string answer = "";
    
    for(int i = 0; i< survey.size(); i++)
    {
        if (choices[i] <= 3)
            alpha[survey[i][0]]+= (4 -choices[i]);
        if (choices[i] > 3)
            alpha[survey[i][1]]+= (choices[i] - 4);
    } 
    if(alpha['T'] > alpha['R']) answer+= 'T';
    else answer += 'R';
    if(alpha['C'] < alpha['F']) answer+= 'F';
    else answer += 'C';
    if(alpha['M'] > alpha['J']) answer+= 'M';
    else answer += 'J';
    if(alpha['N'] > alpha['A']) answer+= 'N';
    else answer += 'A';
    return answer;
}

좀 멍청하게 한 거 일 수 있지만 해냈다