문제 링크 : https://programmers.co.kr/learn/courses/30/lessons/77484
#include <bits/stdc++.h> using namespace std;
int findScore(int value) { if (value == 6) { return 1; } else if (value == 5) { return 2; } else if (value == 4) { return 3; } else if (value == 3) { return 4; } else if (value == 2) { return 5; } else { return 6; } }
vector<int> cmpString(vector<int>& lottos, vector<int>& win_nums) { vector<int> result; int zeroCnt = 0; int sameCnt = 0; for (int i = 0; i < 6; i++) { if (lottos[i] == 0) { zeroCnt++; continue; }
for (int j = 0; j < 6; j++) { if (lottos[i] == win_nums[j]) { sameCnt++; } } }
result.push_back(findScore(sameCnt + zeroCnt)); result.push_back(findScore(sameCnt));
return result; }
vector<int> solution(vector<int> lottos, vector<int> win_nums) { vector<int> answer; answer = cmpString(lottos, win_nums);
return answer; }
|