Advertisement
AnastasiyaG

Untitled

Mar 5th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Exercise
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string input = Console.ReadLine();
  12. input = input.ToLower();
  13. var counts = new Dictionary<string, int>();
  14. for (int i = 0; i < input.Length; i++)
  15. {
  16. char current = input[i];
  17. if (current!=' ')
  18. {
  19. string forAdding = current.ToString();
  20. if (counts.ContainsKey(forAdding))
  21. { counts[forAdding]++; }
  22. else
  23. {
  24. counts.Add(forAdding, 1);
  25. }
  26. }
  27.  
  28. }
  29.  
  30. foreach (var item in counts)
  31. {
  32. Console.WriteLine(item.Key+ " -> "+ item.Value);
  33.  
  34. }
  35. }
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement