728x90
반응형
https://school.programmers.co.kr/learn/courses/30/lessons/81301
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
#include <string>
#include <map>
#include <iostream>
using namespace std;
int solution(string s) {
string stra = "";
map<string, string> kap;
kap["zero"] = "0";
kap["one"] = "1";
kap["two"] = "2";
kap["three"] = "3";
kap["four"] = "4";
kap["five"] = "5";
kap["six"] = "6";
kap["seven"] = "7";
kap["eight"] = "8";
kap["nine"] = "9";
string forstra = "";
for(int i=0;i<s.size();i++)
{
if(s[i] >= '0' && s[i] <= '9')
stra += s[i];
else
{
forstra += s[i];
if(kap.find(forstra) != kap.end())
{
stra += kap[forstra];
forstra = "";
}
}
}
return stoi(stra);
}
728x90
반응형
'자라는 개발자 > 문제풀이' 카테고리의 다른 글
c++ 백준 27964 콰트로치즈피자 (0) | 2023.05.20 |
---|---|
leetcode 169. Majority ElementEasy (0) | 2023.01.15 |
leetcode 383. Ransom Note (0) | 2022.11.13 |
leetcode 387. First Unique Character in a String (0) | 2022.11.13 |
leetcode 350. Intersection of Two Arrays II (0) | 2022.11.13 |