근본없는 코딩

[C++] 백준2941 크로아티아 알파벳 본문

✔ Online Judge

[C++] 백준2941 크로아티아 알파벳

근본없는 개발자 2023. 6. 29. 23:55

 

#include <iostream>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	char str[101];
	int cnt = 0;
	cin >> str;	

	for (int i = 0; i < 101; i++) {
		if (str[i] == '\0') break;
		if (((str[i] == 'c' || str[i] == 'd') && str[i + 1] == '-')
			|| ((str[i] == 'l' || str[i] == 'n') && str[i + 1] == 'j')
			|| ((str[i] == 'c' || str[i] == 's' || str[i] == 'z') && str[i + 1] == '=')) {
			cnt++;
			i++;
		}
		else if (str[i] == 'd' && str[i + 1] == 'z' && str[i + 2] == '=') {
			cnt++;
			i += 2;
		}
		else cnt++;
	}

	cout << cnt << '\n';
	return 0;
}