Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- //You will be given a single string, containing random ASCII character.Your task is to print every character, and how many times it has //been used in the string.
- namespace Letter_Repetition
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<char, int> letters = new Dictionary<char, int>();
- string words = Console.ReadLine();
- for (int i = 0; i < words.Length; i++)
- {
- if (!letters.ContainsKey(words[i]))
- {
- letters.Add(words[i], 0);
- }
- letters[words[i]]++;
- }
- foreach (KeyValuePair<char, int> letter in letters)
- {
- Console.WriteLine($"{letter.Key} -> {letter.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement