Stan0033

Untitled

Jul 17th, 2021
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. namespace apps
  7. {
  8. class Program
  9. {
  10.  
  11. static string Get() { return Console.ReadLine(); }
  12.  
  13. static void Main()
  14. {
  15.  
  16.  
  17.  
  18. string input = Get();
  19. Dictionary<char, int> occurances = new Dictionary<char, int>();
  20. foreach (char c in input)
  21. {
  22. if (c == ' ') { continue; }
  23. if ( occurances.ContainsKey(c) == false )
  24. {
  25. occurances.Add(c, 1);
  26. }
  27. else
  28. {
  29. occurances[c]++;
  30. }
  31. }
  32.  
  33.  
  34. foreach (var v in occurances)
  35. {
  36.  
  37. Console.WriteLine($"{v.Key} -> {v.Value}");
  38.  
  39. }
  40.  
  41. }// END MAIN
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment