C++:: 프로그래머스 < 서울에서 김서방 찾기 >

jahlee·2023년 8월 9일
0

프로그래머스_Lv.1

목록 보기
67/75
post-thumbnail

몇번째 배열에 있는지 찾으면 되는 간단한 문제이다.

#include <string>
#include <vector>

using namespace std;

string solution(vector<string> seoul) {
    string answer = "김서방은 ";
    for (int i=0; i<seoul.size(); i++) {
        if (seoul[i] == "Kim") {
            answer += to_string(i);
            break ;
        }
    }
    answer += "에 있다";
    return answer;
}

0개의 댓글