Repository navigation
Expand file tree
/
Copy pathCroatia_char.java
More file actions
52 lines (44 loc) · 1.43 KB
/
Copy pathCroatia_char.java
File metadata and controls
52 lines (44 loc) · 1.43 KB
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
import java.io.*;
import java.util.*;
class Croatia_char {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
String input = br.readLine();
List<String> alpa = new ArrayList<>();
alpa.add("c=");
alpa.add("c-");
alpa.add("dz=");
alpa.add("d-");
alpa.add("lj");
alpa.add("nj");
alpa.add("s=");
alpa.add("z=");
int result = 0;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < input.length(); i++) {
String c = Character.toString(input.charAt(i));
sb.append(c);
String temp = sb.toString();
for (int j = 0; j < alpa.size(); j++) {
if (temp.contains(alpa.get(j))) {
String s = temp.replaceAll(alpa.get(j), " ");
sb = new StringBuilder();
sb.append(s);
result += 1;
break;
}
}
}
for (int i = 0; i < sb.length(); i++) {
String t = sb.toString();
if (t.charAt(i) != ' ') {
result += 1;
}
}
bw.write(Integer.toString(result));
bw.flush();
bw.close();
br.close();
}
}