Advertisement
Guest User

Untitled

a guest
May 9th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class OddOccurance
  5. {
  6.     static void Main()
  7.     {
  8.         var words = Console.ReadLine().ToLower().Split(' ');
  9.         var result = new List<string>();
  10.  
  11.         var allWords = new Dictionary<string, int>();
  12.         foreach (var word in words)
  13.         {
  14.             if (!allWords.ContainsKey(word))
  15.             {
  16.                 allWords.Add(word, 1);
  17.             }
  18.             else
  19.             {
  20.                 allWords[word]++;
  21.             }
  22.         }
  23.  
  24.         foreach (var item in allWords)
  25.         {
  26.             if (item.Value % 2 == 1)
  27.             {
  28.                 result.Add(item.Key);
  29.             }
  30.         }
  31.  
  32.         Console.WriteLine(string.Join(", ", result));
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement