Advertisement
YavorGrancharov

Letter_Repetition(dict)

Jul 8th, 2017
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Letter_Repetition
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             char[] input = Console.ReadLine().ToCharArray();
  12.             Dictionary<char, int> count = new Dictionary<char, int>();
  13.  
  14.             foreach (var x in input)
  15.             {
  16.                 if (!count.ContainsKey(x))
  17.                 {
  18.                     count[x] = 0;
  19.                 }
  20.                 count[x]++;
  21.             }
  22.             foreach (var c in count)
  23.             {
  24.                 Console.WriteLine($"{c.Key} -> {c.Value}");
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement