개인공부용123 프로그래밍 블로그

[백준]boj2941 본문

카테고리 없음

[백준]boj2941

개인공부용123 2020. 7. 7. 23:11
#include <iostream>
#include <string.h>

using namespace std;

int main() {
	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(NULL);


	char str[101];
	int cnt = 0;

	int i = 0;

	cin >> str;

	while (i < strlen(str)) {
		if (str[i] == 'c') {
			if (str[i + 1] == '=' || str[i + 1] == '-') ++i;
		}
		else if (str[i] == 'd') {
			if (str[i + 1] == '-') ++i;
			else if (str[i + 1] == 'z' && str[i + 2] == '=') i += 2;
		}
		else if (str[i] == 'l' || str[i] == 'n') {
			if (str[i + 1] == 'j') ++i;
		}
		else if (str[i] == 's' || str[i] == 'z') {
			if (str[i + 1] == '=') ++i;
		}

		++i;
		++cnt;
	}

	cout << cnt << endl;
	
	return 0;
}

 

아이디어 : 없음

구현 : if문으로 크로아티아 문자인지 확인하며 처리