반응형
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class BaekjoonAlgo_2941 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
String str = sc.next();
int count = 0;
String[] croAlpha = {"c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z="};
for(int i=0;i<croAlpha.length;i++) {
Pattern p = Pattern.compile(croAlpha[i]);
Matcher m = p.matcher(str);
for (int j = 0; m.find(j); j = m.end()) {
count++;
str = str.replaceAll(croAlpha[i], " ");
}
}
str = str.replaceAll(" ", "");
char[] arr = str.toCharArray();
for(int i=0;i<arr.length;i++) {
count++;
}
System.out.println(count);
}
}
반응형
'알고리즘 > Baekjoon' 카테고리의 다른 글
[Baekjoon] #2571 수 정렬하기 2 (0) | 2022.03.12 |
---|---|
[Baekjoon] #1476 날짜 계산 (0) | 2022.03.11 |
[Baekjoon] #1316 그룹 단어 체커 (0) | 2022.03.08 |
[Baekjoon] #5622 다이얼 (0) | 2022.03.08 |
[Baekjoon] #1152 단어의 개수 (0) | 2022.03.07 |