[BOJ / C++] 2941 크로아티아 알파벳

Seulguo·2022년 7월 19일
0

Algorithm

목록 보기
90/185
post-thumbnail

🐣 문제

링크 : https://www.acmicpc.net/problem/2941


🐥 코드

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

string arr[8] = {"c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="};
int main(){
    string s = "";
    cin >> s;
    
    int idx = 0;
    for(int i = 0; i < 8; i++){
        while(true){
            idx = s.find(arr[i]);
            if(idx != -1) s.replace(idx, arr[i].length(), "!");
            else break;
        }
    }

    cout << s.size();
    
    return 0;
}

0개의 댓글