fork download
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. public class Test
  6. {
  7. static void Main()
  8. {
  9. SortedDictionary<char, int> text = new SortedDictionary<char, int>();
  10. string line = Console.ReadLine();
  11.  
  12. foreach (var character in line)
  13. {
  14. if (text.ContainsKey(character))
  15. {
  16. text[character]++;
  17. }
  18. else
  19. {
  20. text.Add(character, 1);
  21. }
  22. }
  23. foreach (var character in text)
  24. {
  25. Console.WriteLine($"{character.Key} -> {character.Value}");
  26. }
  27. }
  28. }
Success #stdin #stdout 0.01s 131520KB
stdin
text
stdout
e -> 1
t -> 2
x -> 1