NedyalkoKikov

CountLettersInString

May 15th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CountLettersInString
  8. {
  9. class CountLettersInString
  10. {
  11. static void Main(string[] args)
  12. {
  13. string word = Console.ReadLine().ToLower();
  14. int[] count = new int[word.Max()+2];
  15. foreach(char letter in word)
  16. {
  17. count[letter]++;
  18. }
  19. for (int i = 0; i < count.Length; i++)
  20. {
  21. if(count[i] > 0)
  22. {
  23. char letter = (char)i;
  24. int occurrencies = count[i];
  25. Console.WriteLine("{0} ->{1} times",letter,occurrencies);
  26. }
  27. }
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment