find, to_string 쓰면 쉽게 나옴.
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string solution(vector<string> seoul) {
int ind = find(seoul.begin(), seoul.end(), "Kim") - seoul.begin();
return "김서방은 " + to_string(ind) + "에 있다";
}'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV1 수박수박수박수박수박수? (0) | 2022.04.26 |
|---|---|
| [프로그래머스] (C++) LV1 소수 찾기 (0) | 2022.04.26 |
| [프로그래머스] (C++) LV1 문자열 다루기 기본 (0) | 2022.04.26 |
| [프로그래머스] (C++) LV1 문자열 내림차순으로 배치하기 (0) | 2022.04.26 |
| [프로그래머스] (C++) LV1 문자열 내 p와 y의 개수 (0) | 2022.04.26 |