algorithm/BOJ
BOJ 2941번 크로아티아 알파벳
_JunHo
2020. 2. 21. 12:58
BOJ : https://www.acmicpc.net/problem/2941
github : https://github.com/junho0956/Algorithm/blob/master/2941/2941/%EC%86%8C%EC%8A%A4.cpp
문제에서 요구하는 조건 그대로 구현하시면 쉽게 해결됩니다
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
cin >> str;
str += " ";
int cnt = 0;
for (int i = 0; i < str.size()-10; i++) {
if (str[i] == 'l') {
if (str[i + 1] == 'j') cnt++, i++;
else cnt++;
}
else if (str[i] == 'c') {
if (str[i + 1] == '=' || str[i + 1] == '-') cnt++, i++;
else cnt++;
}
else if (str[i] == 'd') {
if (str[i + 1] == 'z' && str[i + 2] == '=') cnt++, i += 2;
else if (str[i + 1] == '-') cnt++, i++;
else cnt++;
}
else if (str[i] == 'n') {
if (str[i + 1] == 'j') cnt++, i++;
else cnt++;
}
else if (str[i] == 's') {
if (str[i + 1] == '=') cnt++, i++;
else cnt++;
}
else if (str[i] == 'z') {
if (str[i + 1] == '=') cnt++, i++;
else cnt++;
}
else cnt++;
}
cout << cnt;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|