Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- import java.util.Scanner;
- public class Speluvanje {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int n = sc.nextInt();
- HashMap<String, String> map = new HashMap<>();
- for(int i =0;i<n;i++){
- String s = sc.next();
- map.put(s, s);
- }
- sc.nextLine();
- String text = sc.nextLine();
- String [] parts = text.split(" ");
- boolean bravo = true;
- for(int i =0;i<parts.length;i++){
- String zbor = parts[i].toLowerCase();
- int dolzina = zbor.length();
- char c = zbor.charAt(dolzina-1);
- if(!Character.isAlphabetic(c)) zbor = zbor.substring(0, dolzina -1);
- String t = map.get(zbor);
- if(t== null){
- System.out.println(zbor);
- bravo = false;
- }
- }
- if(bravo) System.out.println("Bravo");
- }
- }
- TEST:
- 4
- where
- is
- my
- cat
- Where is my cat?
Advertisement
Add Comment
Please, Sign In to add comment