본문 바로가기

Algorithm/BAEKJOON

[BOJ] 2941번 크로아티아 알파벳 (C++)

728x90
반응형

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 cro[8] = { "c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z=" };
	string str;
	cin >> str;
 
	for(int i = 0; i < 8; i++){
		while(1){
			int idx = str.find(cro[i]);
			if(idx == -1) break;
			if(i == 2){
				str.replace(idx, 3, "#");
			} else{
				str.replace(idx, 2, "#");
			}
		}
	}
 
	cout << str.size() << endl;
 
	return 0;
}
728x90
반응형