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

'algorithm > BOJ' 카테고리의 다른 글

BOJ 11654번 아스키 코드  (0) 2020.02.21
BOJ 1149번 RGB거리  (0) 2020.02.21
BOJ 15993번 1, 2, 3 더하기 8  (0) 2020.02.20
BOJ 15992번 1, 2, 3 더하기 7  (0) 2020.02.19
BOJ 15991번 1, 2, 3 더하기 6  (0) 2020.02.18

+ Recent posts