프로그래머스 - 성격 유형 검사하기
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;
}
좀 멍청하게 한 거 일 수 있지만 해냈다
'코딩 공부 연습' 카테고리의 다른 글
소프티어 - H-클린알파 (0) | 2022.09.05 |
---|---|
소프티어 - 성적평균 (0) | 2022.09.04 |
백준 바킹독 BFS 모음 - 1926 그림, 2178 미로탐색, 7576 토마토, 4179 불! (0) | 2022.09.03 |
프로그래머스 짝지어 제거하기 (0) | 2022.09.01 |
프로그래머스 - 구명 보트 (0) | 2022.08.30 |