Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Hashtable<String,String> diccionario = new Hashtable<>();
- Scanner entrada=new Scanner(System.in);
- String A,D,E,F;
- int B,K;
- B=entrada.nextInt();
- String C[]=new String [B];
- for(int i=0;i<B;i++){
- A=entrada.next();
- diccionario.put(A, A);
- C[i]=A;
- }
- for(int j=1;j<C.length;j++){
- D=C[j];
- for(int t=j-1;t>=0;t--){
- if(D.startsWith(C[t])){
- K=C[t].length();
- F=C[j].substring(K);
- if(diccionario.containsKey(F)){
- System.out.println(C[j]+" "+C[t]+" "+F);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement