Advertisement
Guest User

Untitled

a guest
Sep 21st, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class CountSymbols
  6. {
  7.     static void Main()
  8.     {
  9.         string input = Console.ReadLine();
  10.  
  11.         SortedDictionary<char, int> characters = new SortedDictionary<char, int>();
  12.  
  13.         foreach (char character in input)
  14.         {
  15.             if (characters.ContainsKey(character))
  16.             {
  17.                 characters[character]++;
  18.             }
  19.             else
  20.             {
  21.                 characters.Add(character, 1);
  22.             }
  23.         }
  24.  
  25.         char[] charKeys = characters.Keys.ToArray();
  26.  
  27.         foreach (var character in charKeys)
  28.         {
  29.             Console.WriteLine($"{character}: {characters[character]} time/s");
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement