Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace CountCharsInAString
- {
- class Program
- {
- static void Main(string[] args)
- {
- string text = Console.ReadLine();
- var dictionaryCount = new Dictionary<char, int>();
- for (int i = 0; i < text.Length; i++)
- {
- if(text[i]!=' ')
- {
- if (dictionaryCount.ContainsKey(text[i]) == false)
- {
- dictionaryCount[text[i]] = 1;
- }
- else
- {
- dictionaryCount[text[i]]++;
- }
- }
- }
- foreach (var kvp in dictionaryCount)
- {
- Console.WriteLine($"{kvp.Key} -> {kvp.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement