AlbertMourato

Untitled

Dec 7th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Main {
  4.     public static void main(String args[]){
  5.         Scanner in = new Scanner(System.in);
  6.         int n;
  7.         String entrada;
  8.         String atalho[] = new String[15000];
  9.         String saida = "";
  10.         int k;
  11.         int l = 0;
  12.         n = in.nextInt();
  13.         entrada = in.nextLine();
  14.         String come;
  15.         while(n>0){
  16.             entrada = in.nextLine();
  17.             k = in.nextInt();
  18.             come = in.nextLine();
  19.             saida = "";
  20.             if(k==0){
  21.                 System.out.println(entrada);
  22.             }else{
  23.                 for(int i = 0;i<k;i++){
  24.                     atalho[i] = in.nextLine();
  25.                 }
  26.                 for(int i = 0;i<entrada.length()-1;i++){
  27.                     if(entrada.charAt(i)=='*'&&entrada.charAt(i+1)!='*'){
  28.                         for(int j = 0;j<k;j++){
  29.                             if(entrada.charAt(i+1)==atalho[j].charAt(0)){
  30.                                 saida+=atalho[j].substring(atalho[j].indexOf(" ")+1, atalho[j].length());
  31.                             }
  32.                         }
  33.                         i++;
  34.                     }else{
  35.                         saida+=entrada.charAt(i);
  36.                     }
  37.                 }
  38.                 if(entrada.charAt(entrada.length()-2)!='*')saida+=entrada.charAt(entrada.length()-1);
  39.                 System.out.println(saida);
  40.             }
  41.             n--;
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment