728x90
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/77484
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<int> lottos, vector<int> win_nums) {
vector<int> answer;
int cnt1 = 0, cnt2 = 0;
for(int i = 0; i < 6; i++){
if(find(win_nums.begin(), win_nums.end(), lottos[i]) != win_nums.end()){
cnt1++;
cnt2++;
}
else if(lottos[i] == 0){
cnt1++;
}
}
if(cnt1 == 6) answer.push_back(1);
else if(cnt1 == 5) answer.push_back(2);
else if(cnt1 == 4) answer.push_back(3);
else if(cnt1 == 3) answer.push_back(4);
else if(cnt1 == 2) answer.push_back(5);
else answer.push_back(6);
if(cnt2 == 6) answer.push_back(1);
else if(cnt2 == 5) answer.push_back(2);
else if(cnt2 == 4) answer.push_back(3);
else if(cnt2 == 3) answer.push_back(4);
else if(cnt2 == 2) answer.push_back(5);
else answer.push_back(6);
return answer;
}
728x90
반응형
'Algorithm > Programmers' 카테고리의 다른 글
[Programmers] 성격 유형 검사하기 (C++) (0) | 2023.02.21 |
---|---|
[Programmers] 개인정보 수집 유효기간 (C++) (0) | 2023.02.20 |
[Programmers] 거리두기 확인하기 (C++) (0) | 2022.04.29 |
[Programmers] 숫자 문자열과 영단어 (C++) (0) | 2022.02.18 |
[Programmers] 신규 아이디 추천 (C++) (0) | 2022.02.18 |