프로그래머스 12919 서울에서 김서방 찾기

1 개요[ | ]

프로그래머스 12919 서울에서 김서방 찾기

2 C++[ | ]

#include <string>
#include <vector>

using namespace std;

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

string solution(vector<string> seoul) {
    int pos = find(seoul.begin(), seoul.end(), "Kim") - seoul.begin();
    return "김서방은 "+to_string(pos)+"에 있다";
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}