Crazy

Speluvanje

May 28th, 2018
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. import java.util.HashMap;
  2. import java.util.Scanner;
  3.  
  4. public class Speluvanje {
  5.     public static void main(String[] args) {
  6.         Scanner sc = new Scanner(System.in);
  7.         int n = sc.nextInt();
  8.         HashMap<String, String> map = new HashMap<>();
  9.         for(int i =0;i<n;i++){
  10.             String s = sc.next();
  11.             map.put(s, s);
  12.         }
  13.         sc.nextLine();
  14.         String text = sc.nextLine();
  15.         String [] parts = text.split(" ");
  16.         boolean bravo = true;
  17.         for(int i =0;i<parts.length;i++){
  18.             String zbor = parts[i].toLowerCase();
  19.             int dolzina = zbor.length();
  20.             char c = zbor.charAt(dolzina-1);
  21.             if(!Character.isAlphabetic(c)) zbor = zbor.substring(0, dolzina -1);
  22.             String t = map.get(zbor);
  23.             if(t== null){
  24.                 System.out.println(zbor);
  25.                 bravo = false;
  26.             }
  27.         }
  28.         if(bravo) System.out.println("Bravo");
  29.        
  30.     }
  31. }
  32.  
  33.  
  34. TEST:
  35. 4
  36. where
  37. is
  38. my
  39. cat
  40. Where is my cat?
Advertisement
Add Comment
Please, Sign In to add comment