오락기/codeWar
백준 2941 크로아티아 알파벳
문방구앞오락기
2018. 5. 25. 11:28
크로아티아 알파벳 | 변경 |
---|---|
č | c= |
ć | c- |
dž | dz= |
ñ | d- |
lj | lj |
nj | nj |
š | s= |
ž | z= |
이고 위에 없는 알파벳은 한글자씩 샌다
ljes=njak
6
ddz=z=
3
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 | import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.nextLine().trim(); String str = input; // String str = "nljj"; int count = str.length(); // dz // lj // nj for(int i=0 ; i<str.length() ; i++) { // System.out.println(str.charAt(i)); if(str.charAt(i) == '=' || str.charAt(i) == '-') { count--; // System.out.println("= - 빼기"); } if( (str.charAt(i) == 'd' && str.length() - i >= 3) && str.charAt(i+1) == 'z' && str.charAt(i+2) == '=') { count--; count--; i++; i++; // System.out.println("dz"); } if((str.charAt(i) == 'l' && str.length() - i >= 2) && str.charAt(i+1) == 'j') { count--; i++; // System.out.println("lj"); } if((str.charAt(i) == 'n' && str.length() - i >= 2) && str.charAt(i+1) == 'j') { count--; i++; // System.out.println("nj"); } } System.out.println(count); } } |