프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이과정
Kim과 일치하는 값이 있으면 index값을 idx에 저장해준다.
#include <string>
#include <vector>
using namespace std;
string solution(vector<string> seoul) {
string answer = "";
int idx;
for(int i = 0; i < seoul.size(); i++){
if(seoul[i] == "Kim") idx = i;
}
answer += "김서방은 " + to_string(idx) + "에 있다";
return answer;
}
'🍞 Problem Solving > Programmers' 카테고리의 다른 글
[프로그래머스][Level1] 수박수박수박수박수박수? c++ (0) | 2022.09.02 |
---|---|
[프로그래머스][Level1] 소수 찾기 c++ (0) | 2022.09.02 |
[프로그래머스][Level1] 최소 직사각형 c++ (0) | 2022.09.02 |
[프로그래머스][Level1] [1차] 다트 게임 c++ (0) | 2022.09.02 |
[프로그래머스][Level1] 부족한 금액 계산하기 c++ (0) | 2022.09.02 |