Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.HashMap;
- public class KumanovskiDijalekt {
- public static void main(String[] args) {
- Scanner std = new Scanner(System.in);
- int N = Integer.parseInt(std.nextLine());
- String[] s;
- HashMap<String, String> tabela = new HashMap<>();
- for (int i = 0; i < N; i++) {
- s = std.nextLine().split(" ");
- tabela.put(s[0], s[1]);
- }
- String[] text = std.nextLine().split(" ");
- String nov = "",temp="",bez="";
- Character znak;
- for (int i = 0; i < text.length; i++) {
- nov=Character.toLowerCase(text[i].charAt(0))+text[i].substring(1,text[i].length());
- bez=text[i].substring(0,text[i].length()-1);
- znak = text[i].charAt(text[i].length()-1);
- if (tabela.containsKey(text[i])) {
- System.out.print(tabela.get(text[i]) + " ");
- }
- else if(tabela.containsKey(nov)) {
- temp=Character.toUpperCase(tabela.get(nov).charAt(0)) + tabela.get(nov).substring(1,tabela.get(nov).length());
- System.out.print(temp + " ");
- }
- else if(tabela.containsKey(bez))
- {
- System.out.print(tabela.get(bez)+znak+" ");
- }
- else System.out.print(text[i] + " ");
- }
- }
- }
Add Comment
Please, Sign In to add comment