Advertisement
YavorGrancharov

Odd_Occurrences(dict)

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