본문 바로가기
Programming/Algorithm

백준 크로아티아

by OKOK 2018. 1. 25.

/*

단어가 주어졌을 때 몇개의 크로아티아 알파벳으로 이루어져 있는지 출력합니다.

여기에 안나온 변경치는 그냥 한의 단어로 세면 됩니다. 오케이요 일단 받아보도록 하겠습니다.


ljes=njak 를 받았다고 가정합니다.

*/


#include <iostream>

#include <string>


using namespace std;


string word;

int ans = 0;


void problemIn() {

cin >> word;

}


void solve() {

ans = word.length();

for (int i = 0; i < word.length(); i++) {

if (word[i] == 'l') {

if (word[i + 1] == 'j') {

ans--;

}

}


else if (word[i] == 'c') {

if (word[i + 1] == '=' || word[i + 1] == '-') {

ans--;

}

}


else if (word[i] == 'd') {

if (word[i + 1] == '-') {

ans--;

}

else if (word[i + 1] == 'z') {

if (word[i + 2] == '=') {

ans--;

}

}

}

else if (word[i] == 'n') {

if (word[i + 1] == 'j') {

ans--;

}

}


else if (word[i] == 's') {

if (word[i + 1] == '=') {

ans--;

}

}


else if (word[i] == 'z') {

if (word[i + 1] == '=') {

ans--;

}

}

}


cout << ans << endl;

}


int main() {

problemIn();

solve();

return 0;


문자열 입력 오케이요. 입력받아서 하나씩 처리해나가는 것 처리했습니다. 다음 단계로 가즈아!!!