본문 바로가기

Programming/Algorithm (C++)

[백준 2941번] C언어 :: 크로아티아 알파벳

#include <stdio.h>
#include <string.h>
int main() {

	
	char s[100];
	int i;
	int count = 0;
	scanf("%s", s);

	count = strlen(s);
	for (i = 0; i < strlen(s); i++) {
		if (s[i] == 'c' || s[i] == 's' || s[i] == 'z') {
			if (s[i + 1] == '=') {
				count--;
			}
		}
		if (s[i] == 'n' || s[i] == 'l') {
			if (s[i + 1] == 'j') {
				count--;
			}
		}
		if (s[i] == 'c' || s[i] == 'd') {
			if (s[i + 1] == '-') {
				count--;
			}
		}

		if (s[i] == 'd'){
			if (s[i + 1] == 'z') {
				if(s[i+2]=='=')
				count--;
			}
		}

	}

		printf("%d\n", count);
	
		
}

크로아티아 알파펫이 나오면 count를 줄여나갔다.