프로그래머스 코딩테스트 연습 > 2021 카카오 채용연계형 인턴십 > 숫자 문자열과 영단어
#include <string>
#include <map>
using namespace std;
map<string, int> m;
int solution(string s) {
string answer;
// 맵 초기화
m["zero"] = 0;
m["one"] = 1;
m["two"] = 2;
m["three"] = 3;
m["four"] = 4;
m["five"] = 5;
m["six"] = 6;
m["seven"] = 7;
m["eight"] = 8;
m["nine"] = 9;
// 버퍼
string buffer;
for(auto c : s)
{
// 숫자인지 확인
if(isdigit(c))
answer += c;
else
buffer += c;
// 버퍼 문자열 확인
if(m.find(buffer) != m.end())
{
answer += to_string(m[buffer]);
buffer.clear();
}
}
return stoi(answer);
}
string
char