Advertisement
Stan0033

Untitled

Jul 17th, 2021
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 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. string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  17.  
  18. string input = Get();
  19. Dictionary<char, int> occurances = new Dictionary<char, int>();
  20. foreach (char c in input)
  21. {
  22. if (alphabet.Contains(c) == true && occurances.ContainsKey(c) == false)
  23. {
  24. occurances.Add(c, 0);
  25. }
  26. }
  27. foreach (char c in input)
  28. {
  29. if (c != ' ')
  30. {
  31. occurances[c]++;
  32. }
  33. }
  34.  
  35. foreach( var v in occurances)
  36. {
  37. Console.WriteLine($"{v.Key} -> {v.Value}");
  38. }
  39.  
  40. }// END MAIN
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement