Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Zbor implements Comparable<Zbor>{
- String zbor;
- public Zbor(String zbor) {
- this.zbor = zbor;
- }
- @Override
- public boolean equals(Object obj) {
- Zbor pom = (Zbor) obj;
- return this.zbor.equals(pom.zbor);
- }
- @Override
- public int hashCode() {
- return zbor.hashCode();
- }
- @Override
- public String toString() {
- return zbor;
- }
- @Override
- public int compareTo(Zbor arg0) {
- return zbor.compareTo(arg0.zbor);
- }
- }
- public class Speluvanje {
- public static void main(String[] args) {
- Scanner in=new Scanner(System.in);
- int n=Integer.parseInt(in.nextLine());
- OBHT<Zbor, Zbor> table=new OBHT<>(2*n);
- for(int i=0;i<n;i++){
- String word=in.nextLine();
- Zbor z=new Zbor(word);
- table.insert(z,z);
- }
- String text=in.nextLine();
- String [] parts=text.split(" ");
- int nepravilno=0;
- for(int i=0;i<parts.length;i++){
- if(parts[i].equals("."))
- break;
- String word=parts[i];
- if(!Character.isLetter(parts[i].charAt(parts[i].length()-1))) {
- word = parts[i].substring(0, parts[i].length() - 1);
- }
- word=word.substring(0,1).toLowerCase()+word.substring(1).toLowerCase();
- int index=table.search(new Zbor(word));
- if(index==-1){
- System.out.println(word);
- nepravilno++;
- continue;
- }
- if(table.getValue(index).compareTo(new Zbor(word))!=0){
- System.out.println(word);
- nepravilno++;
- }
- }
- if(nepravilno==0){
- System.out.println("Bravo");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement