별의 공부 블로그 🧑🏻‍💻
728x90
728x170

문제

예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 다음과 같이 변경해서 입력했다.


크로아티아 알파벳

변경 

č

c=

ć

c-

dz=

ñ

d-

lj

lj

nj

nj

š

s=

ž

z=


예를 들어, ljes=njak은 크로아티아 알파벳 6개(lj, e, š, nj, a, k)로 이루어져 있다.

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


 

입력

첫째 줄에 최대 100글자의 단어가 주어진다. 알파벳 소문자와 '-', '='로만 이루어져 있다.

문제 설명에 나와있는 크로아티아 알파벳만 주어진다.

 

 

출력

입력으로 주어진 단어가 몇 개의 크로아티아 알파벳으로 이루어져 있는지 출력한다.

 

 

예제 입력

 ljes=njak

 

예제 출력

 6

 

 

힌트

 

 

출처

Contest > Croatian Open Competition in Informatics > COCI 2008/2009 > Contest #5 1번 

· 문제를 번역한 사람: baekjoon 

· 데이터를 추가한 사람: handong veydpz zzangho 

 

 

코드

 

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <string.h>    // strlen()
 
#define N 100
 
using namespace std;
 
int main()
{
    // 'c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z='
 
    char input[100];
    int len, cnt = 0;
 
    cin >> input;
 
    len = strlen(input);
 
    for (int i = 0; i < len; i++) {
        if ((input[i] == 'c'&& (input[i + 1== '=')) {
            cnt++;
            i += 1;
        }
        else if ((input[i] == 'c'&& (input[i + 1== '-')) {
            cnt++;
            i += 1;
        }
        else if ((input[i] == 'd'&& (input[i + 1== 'z'&& (input[i + 2== '=')) {
            cnt++;
            i += 2;
        }
        else if ((input[i] == 'd'&& (input[i + 1== '-')) {
            cnt++;
            i += 1;
        }
        else if ((input[i] == 'l'&& (input[i + 1== 'j')) {
            cnt++;
            i += 1;
        }
        else if ((input[i] == 'n'&& (input[i + 1== 'j')) {
            cnt++;
            i += 1;
        }
        else if ((input[i] == 's'&& (input[i + 1== '=')) {
            cnt++;
            i += 1;
        }
        else if ((input[i] == 'z'&& (input[i + 1== '=')) {
            cnt++;
            i += 1;
        }
        else {
            cnt++;
        }
    }
    
    cout << cnt << endl;
 
    return 0;
}
cs

728x90
그리드형(광고전용)
⚠️AdBlock이 감지되었습니다. 원할한 페이지 표시를 위해 AdBlock을 꺼주세요.⚠️
starrykss
starrykss
별의 공부 블로그 🧑🏻‍💻


📖 Contents 📖