Advertisement
Guest User

Untitled

a guest
May 27th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 KB | None | 0 0
  1. import java.util.*;
  2. public class Main {
  3.  
  4.     public static void main(String[] args) {
  5.     Hashtable<String,String> diccionario = new Hashtable<>();
  6.     Scanner entrada=new Scanner(System.in);
  7.     String A,D,E,F;
  8.     int B,K;
  9.    
  10.     B=entrada.nextInt();
  11.     String C[]=new String [B];
  12.    
  13.         for(int i=0;i<B;i++){
  14.             A=entrada.next();
  15.             diccionario.put(A, A);
  16.             C[i]=A;
  17.         }
  18.    
  19.         for(int j=1;j<C.length;j++){
  20.             D=C[j];
  21.            
  22.             for(int t=j-1;t>=0;t--){
  23.                 if(D.startsWith(C[t])){
  24.                     K=C[t].length();
  25.                     F=C[j].substring(K);
  26.                
  27.                     if(diccionario.containsKey(F)){
  28.                         System.out.println(C[j]+" "+C[t]+" "+F);
  29.                     }  
  30.                 }
  31.             }
  32.         }    
  33.     }  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement