Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package dopolnitelni_casovi.hashmaps;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.HashMap;
- import java.util.Map;
- /**
- * ----------------------------
- * Project: APS
- * Package: dopolnitelni_casovi.hashmaps
- * Created on: 28.5.2016, 00:39
- * IDE: IntelliJ IDEA
- * ----------------------------
- * Author: Damjan Miloshevski
- * Web: http://damjanmiloshevski.mk/
- * Phone: +389 (0)78 566 409
- * E-mail: [email protected]; [email protected]
- * Skype: damjan.milosevski
- * LinkedIn: https://mk.linkedin.com/in/damjanmiloshevski
- * GitHub: https://github.com/damsii
- * Bitbucket: https://bitbucket.org/dam_si
- */
- public class Speluvanje {
- public static void main(String[] args) throws IOException {
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
- Map<String, String> map = new HashMap<>();
- try {
- int N = Integer.parseInt(in.readLine());
- for (int i = 0; i < N; i++) {
- String zbor = in.readLine();
- map.put(zbor, zbor);
- }
- String[] zborovi = in.readLine().split(" ");
- boolean f = true;
- for (int i = 0; i < zborovi.length; i++) {
- String zbor = removePunct(zborovi[i].toLowerCase());
- String z = map.get(zbor);
- if (z == null) {
- System.out.println(zbor);
- f = false;
- }
- }
- if (f) {
- System.out.println("Bravo");
- }
- } catch (NumberFormatException e) {
- System.err.println("Pogresen vlez! Treba da vnesete cel broj!");
- }
- in.close();
- }
- static String removePunct(String word) {
- String zbor = null;
- char c = word.charAt(word.length() - 1);
- if (!Character.isAlphabetic(c)) {
- zbor = word.substring(0, word.length() - 1);
- } else {
- zbor = word;
- }
- return zbor;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment