fork(1) 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. char[] characters = Console.ReadLine()
  11. .ToArray();
  12.  
  13. foreach (var character in characters)
  14. {
  15. if (text.ContainsKey(character))
  16. {
  17. text[character]++;
  18. }
  19. else
  20. {
  21. text.Add(character, 1);
  22. }
  23. }
  24. foreach (var character in text)
  25. {
  26. Console.WriteLine($"{character.Key} -> {character.Value}");
  27. }
  28. }
  29. }
Success #stdin #stdout 0.01s 132544KB
stdin
text
stdout
e -> 1
t -> 2
x -> 1