Advertisement
Guest User

7.Odd_Occurrences

a guest
Aug 6th, 2016
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 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 _7.Odd_Occurrences
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var text = Console.ReadLine().ToLower();
  14. var words = text.Split(' ');
  15. var counts = new Dictionary<string, int>();
  16. foreach (var w in words)
  17. {
  18. if (counts.ContainsKey(w)) counts[w]++;
  19. else counts[w] = 2;
  20. }
  21.  
  22. var list = new List<string>();
  23. foreach (var pair in counts)
  24. {
  25. if (pair.Value % 2 !=0)
  26. {
  27. list.Add(pair.Key);
  28. }
  29. }
  30. Console.WriteLine(string.Join(", ",list));
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement