성격 유형 검사하기 (Kakao)

이주희·2023년 2월 21일
0

Algorithm

목록 보기
16/24
#include <string>
#include <vector>

using namespace std;
int alpha[40];
int score[4][2];

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

0개의 댓글