디팔이의 개발공부/백준풀이 및 연습
[백준] 2941 - 크로아티아 알파벳 (미해결)
디팔⸜( ◜࿁◝ )⸝︎︎
2022. 10. 14. 17:11
import java.util.Scanner;
public class main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("크로아티아어를 입력하세요");
String inputAlphabet = sc.next();
System.out.println(getCountWords(inputAlphabet));
}
static int getCountWords(String alphabet){
int count = 0;
String[] newAlphabet = alphabet.split("",100);
for(int i=0; i<(newAlphabet.length)-1; i++){
if(newAlphabet[i].equals("c")){
if((newAlphabet[i+1].equals("="))||(newAlphabet[i+1].equals("-"))){
count--;
}
}
if(newAlphabet[i].equals("d")){
if(newAlphabet[i+1].equals("z")) {
if (newAlphabet[i+2].equals("=")) {
count --;
}
}
if(newAlphabet[i+1].equals("-")){
count--;
}
}
if((newAlphabet[i].equals("l")) || (newAlphabet[i].equals("n"))){
if(newAlphabet[i+1].equals("j")){
count--;
}
}
if((newAlphabet[i].equals("s")) || (newAlphabet[i].equals("z"))){
if(newAlphabet[i+1].equals("=")){
count--;
}
}
count++;
}
return count;
}
}
외않되~~~갸르륵