Posts [프로그래머스] 서울에서 김서방 찾기 / C++
Post
Cancel

[프로그래머스] 서울에서 김서방 찾기 / C++


Contents



문제


문제를 보시려면 링크를 클릭해주세요.


풀이


to_string 함수를 이용하여 숫자를 문자열로 변환할 수 있습니다.

int to string


소스 코드


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#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;
        }
    }
    
    return answer;
}



This post is licensed under CC BY 4.0 by the author.

[iPlanet] iPlanet SSL 인증서 등록 방법

[프로그래머스] 완주하지 못한 선수 / C++

Comments powered by Disqus.