Advertisement
deyanmalinov

03. Periodic Table

Jun 1st, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. package DPM;
  2.  
  3. import java.util.Scanner;
  4. import java.util.TreeSet;
  5.  
  6. public class Main {
  7.     public static void main(String[] args){
  8.         Scanner scan = new Scanner(System.in);
  9.         int num = scan.nextInt();
  10.         TreeSet<String > elements = new TreeSet<>();
  11.         for (int i = 0; i < num; i++) {
  12.             String[] line = scan.nextLine().split(" ");
  13.             for (int j = 0; j < line.length; j++) {
  14.                 elements.add(line[j]);
  15.  
  16.             }
  17.  
  18.         }
  19.         for (String element : elements) {
  20.             System.out.print(element+ " ");
  21.         }
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement