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;
- namespace CountLettersInString
- {
- class CountLettersInString
- {
- static void Main(string[] args)
- {
- string word = Console.ReadLine().ToLower();
- int[] count = new int[word.Max()+2];
- foreach(char letter in word)
- {
- count[letter]++;
- }
- for (int i = 0; i < count.Length; i++)
- {
- if(count[i] > 0)
- {
- char letter = (char)i;
- int occurrencies = count[i];
- Console.WriteLine("{0} ->{1} times",letter,occurrencies);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment