성격 유형 검사하기

bgy·2022년 9월 5일
0

보기의 표나 문자를 배열에 넣어놓고 꺼내쓰기
map -> 키,값 쌍

#include <string>
#include <vector>

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

0개의 댓글