Facebook
From Lousy Armadillo, 3 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 128
  1. import java.util.*;
  2. public class Main {
  3.     public static void main(String args[]) {
  4.         LinkedList < String > list = new LinkedList < String > ();
  5.         LinkedList < String > list2 = new LinkedList < String > ();
  6.         int currentWordIndex = 0;
  7.  
  8.         Scanner scanner = new Scanner(System.in);
  9.         do {
  10.             String line = scanner.nextLine();
  11.  
  12.             if (line.equals("STOP")) {
  13.                 break;
  14.             }
  15.  
  16.             list.add(line);
  17.         }
  18.         while (true);
  19.  
  20.         do {
  21.             if (list2.indexOf(list.get(currentWordIndex)) == -1) {
  22.                 list2.add(list.get(currentWordIndex));
  23.             }
  24.  
  25.             currentWordIndex ++;
  26.         }
  27.         while (currentWordIndex < list.size());
  28.    
  29.         System.out.println("Prima lista");
  30.         Iterator < String > iterator1 = list.iterator();
  31.         while (iterator1.hasNext()) {
  32.             System.out.println(iterator1.next());
  33.         }
  34.        
  35.         System.out.println("--------");
  36.         System.out.println("A doua lista");
  37.         Iterator < String > iterator2 = list2.iterator();
  38.         while (iterator2.hasNext()) {
  39.             System.out.println(iterator2.next());
  40.         }
  41.     }
  42. }