Advertisement
Militsa

01. Odd Occurences

Dec 7th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _01.Odd_Occurences
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var input = Console.ReadLine().ToLower().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  14.             var words = new Dictionary<string,int>();
  15.  
  16.             foreach (var word in input)
  17.             {
  18.                 if (words.ContainsKey(word))
  19.                 {
  20.                     words[word]++;
  21.                 }
  22.                 else
  23.                 {
  24.                     words[word] = 1;
  25.                 }
  26.             }
  27.             var result = new List<string>();
  28.             foreach (var pair in words)
  29.             {
  30.                 if (pair.Value % 2 == 1)
  31.                 {
  32.                     result.Add(pair.Key);
  33.                 }
  34.             }
  35.             Console.Write(string.Join(", ", result));
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement