DamSi

Untitled

May 27th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.07 KB | None | 0 0
  1. package dopolnitelni_casovi.hashmaps;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.util.HashMap;
  7. import java.util.Map;
  8.  
  9. /**
  10.  * ----------------------------
  11.  * Project: APS
  12.  * Package: dopolnitelni_casovi.hashmaps
  13.  * Created on: 28.5.2016, 00:39
  14.  * IDE: IntelliJ IDEA
  15.  * ----------------------------
  16.  * Author: Damjan Miloshevski
  17.  * Web: http://damjanmiloshevski.mk/
  18.  * Phone: +389 (0)78 566 409
  19.  * Skype: damjan.milosevski
  20.  * LinkedIn: https://mk.linkedin.com/in/damjanmiloshevski
  21.  * GitHub: https://github.com/damsii
  22.  * Bitbucket: https://bitbucket.org/dam_si
  23.  */
  24. public class Speluvanje {
  25.     public static void main(String[] args) throws IOException {
  26.         BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  27.         Map<String, String> map = new HashMap<>();
  28.         try {
  29.             int N = Integer.parseInt(in.readLine());
  30.             for (int i = 0; i < N; i++) {
  31.                 String zbor = in.readLine();
  32.                 map.put(zbor, zbor);
  33.             }
  34.             String[] zborovi = in.readLine().split(" ");
  35.             boolean f = true;
  36.             for (int i = 0; i < zborovi.length; i++) {
  37.                 String zbor = removePunct(zborovi[i].toLowerCase());
  38.                 String z = map.get(zbor);
  39.                 if (z == null) {
  40.                     System.out.println(zbor);
  41.                     f = false;
  42.                 }
  43.             }
  44.             if (f) {
  45.                 System.out.println("Bravo");
  46.             }
  47.         } catch (NumberFormatException e) {
  48.             System.err.println("Pogresen vlez! Treba da vnesete cel broj!");
  49.         }
  50.         in.close();
  51.     }
  52.  
  53.     static String removePunct(String word) {
  54.         String zbor = null;
  55.         char c = word.charAt(word.length() - 1);
  56.         if (!Character.isAlphabetic(c)) {
  57.             zbor = word.substring(0, word.length() - 1);
  58.         } else {
  59.             zbor = word;
  60.         }
  61.         return zbor;
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment