Advertisement
tpwls8122

Untitled

Feb 17th, 2019
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class 크로아티아알파벳 {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.  
  8.         char[] word = sc.nextLine().toCharArray();
  9.         int len = word.length;
  10.  
  11.         int wordCnt = 0;
  12.         char prec;
  13.         for (int i = len - 1; i >= 0; i--) {
  14.             char c = word[i];
  15.  
  16.             switch (c) {
  17.             case '=': // 4개
  18.                 prec = word[i - 1];
  19.                 if (prec == 'c') {
  20.                     i--;
  21.                 } else if (prec == 'z') {
  22.                     if (i - 2 >= 0 && word[i - 2] == 'd') {
  23.                         i -= 2;
  24.                     } else {
  25.                         i--;
  26.                     }
  27.                 } else if (prec == 's') {
  28.                     i--;
  29.                 }
  30.                 wordCnt++;
  31.                 break;
  32.             case '-': // 2개
  33.                 prec = word[i - 1];
  34.                 if (prec == 'c') {
  35.                     i--;
  36.                 } else if (prec == 'd') {
  37.                     i--;
  38.                 }
  39.                 wordCnt++;
  40.                 break;
  41.             case 'j': // 2개
  42.                 prec = word[i - 1];
  43.                 if (prec == 'l') {
  44.                     i--;
  45.                 } else if (prec == 'n') {
  46.                     i--;
  47.                 }
  48.                 wordCnt++;
  49.                 break;
  50.             default:
  51.                 wordCnt++;
  52.                 break;
  53.             }
  54.  
  55.         }
  56.         System.out.println(wordCnt);
  57.  
  58.         sc.close();
  59.     }
  60.  
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement