알고리즘/백준(BOJ)
백준 - 2941 크로아티아 알파벳
시나모온
2020. 8. 28. 17:34
문제 링크입니다 : https://www.acmicpc.net/problem/2941
2941번: 크로아티아 알파벳
예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z=
www.acmicpc.net
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
cin >> str;
string chroatia[8] = {"c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="};
for(int i = 0; i < 8; i++) {
int index = 0;
while(true)
{
index = str.find(chroatia[i], index);
if(index == string::npos) break;
str.replace(index, chroatia[i].length(), "A");
index += 1; // 바꾼 길이 만큼 "A"만큼
}
}
cout << str.size();
return 0;
}
개발 환경 : vscode
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~