fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace _02_ExtractOddOccurrence
  7. {
  8. class oddOccurrence
  9. {
  10. static void Main(string[] args)
  11. {
  12. string inputStr = "C#, SQL, PHP, PHP, SQL, SQL";
  13. char[] separators = new char[] { ',', ' ', '.', '-', '_' };
  14. string[] words = inputStr.Split(separators, StringSplitOptions.RemoveEmptyEntries);
  15. Dictionary<string, int> wordCount = new Dictionary<string, int>();
  16. foreach (string word in words)
  17. {
  18. if (wordCount.ContainsKey(word))
  19. {
  20. wordCount[word]++;
  21. }
  22. else
  23. {
  24. wordCount.Add(word, 1);
  25. }
  26. }
  27. Console.Write("{");
  28. foreach (KeyValuePair<string,int> pair in wordCount)
  29. {
  30. if (pair.Value % 2 != 0)
  31. {
  32. Console.Write("{0},", pair.Key);
  33. }
  34. }
  35. Console.WriteLine("}.");
  36. }
  37. }
  38. }
  39.  
Success #stdin #stdout 0.04s 37056KB
stdin
Standard input is empty
stdout
{C#,SQL,}.