250x250
반응형
Notice
Recent Posts
Recent Comments
Link
N
(프로그래머스 c++) [PCCE 기출문제] 5번 / 심폐소생술 본문
728x90
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/340203
프로그래머스
SW개발자를 위한 평가, 교육의 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
주어진 cpr과 basic_order를 순회하면서 같은 값이면 해당 인덱스 값을 +1 해서 answer에 있는 값을 바꿔주는 문제.
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<string> cpr) {
vector<int> answer = {0, 0, 0, 0, 0};
vector<string> basic_order = {"check", "call", "pressure", "respiration", "repeat"};
for(int i=0; i< cpr.size(); i++){ // 빈칸
for(int j=0; j< basic_order.size(); j++){ // 빈칸
if(cpr[i] == basic_order[j]){
answer[i] = j + 1; // 빈칸
break;
}
}
}
return answer;
}728x90
반응형
'프로그래머스 알고리즘 > 0 & 1단계' 카테고리의 다른 글
| (프로그래머스 c++) [PCCP 기출문제] 1번 / 동영상 재생기 (1) | 2025.08.02 |
|---|---|
| (프로그래머스 C++)상자 꺼내기 (3) | 2025.07.27 |
| (프로그래머스 c++)[PCCE 기출문제] 4번 / 병과분류 (0) | 2025.07.26 |
| [PCCE 기출문제] 3번 / 수 나누기 (0) | 2025.07.26 |
| (프로그래머스 c++)[PCCE 기출문제] 2번 / 각도 합치기 (1) | 2025.07.26 |