Advertisement
simonradev

PeriodicTable

May 26th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.04 KB | None | 0 0
  1. namespace PeriodicTable
  2. {
  3.     using System;
  4.     using System.Collections.Generic;
  5.     using System.Linq;
  6.     using System.Text;
  7.     using System.Threading.Tasks;
  8.    
  9.     public class Startup
  10.     {
  11.         public static void Main()
  12.         {
  13.             SortedSet<string> chemicalElements = new SortedSet<string>();
  14.  
  15.             int countOfInputLines = int.Parse(Console.ReadLine());
  16.             for (int currLine = 0; currLine < countOfInputLines; currLine++)
  17.             {
  18.                 string[] inputLine = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  19.  
  20.                 inputLine.ForEach(s => chemicalElements.Add(s));
  21.             }
  22.  
  23.             Console.WriteLine(string.Join(" ", chemicalElements));
  24.         }
  25.     }
  26.  
  27.     public static class ExtensionMethod
  28.     {
  29.         public static void ForEach(this string[] array, Action<string> actionToExecute)
  30.         {
  31.             foreach (string item in array)
  32.             {
  33.                 actionToExecute(item);
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement