Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- namespace N_redica
- {
- class Program
- {
- static void Main(string[] args)
- {
- string inputLine;
- Console.OutputEncoding = Encoding.UTF8;
- Console.InputEncoding = Encoding.UTF8;
- int countDigits = 0;
- int countWordsSum = 0;
- //char[] letters = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
- SortedDictionary<char, int> histogram = new SortedDictionary<char, int>();
- do
- {
- inputLine = Console.ReadLine();
- inputLine.ToLower();
- string[] words = inputLine.Split(new char[] {',', '.', ' ',';',':','?','!','-','(',')','"','/'}, StringSplitOptions.RemoveEmptyEntries);
- char[] charArr = inputLine.ToCharArray();
- foreach(var item in charArr)
- {
- if (item>=97 && item<=122)
- {
- if (histogram.ContainsKey(item) )
- {
- histogram[item]++;
- }
- else
- {
- histogram[item]=1;
- }
- }
- if (item <= 57 && item>=48)
- {
- countDigits += 1;
- }
- }
- /* foreach(var item in words)
- {
- Console.Write(item+" ");
- }
- */
- countWordsSum += words.Length;
- } while (!inputLine.Equals(""));
- Console.WriteLine("Total words in the text: " + countWordsSum);
- Console.WriteLine("Total digits in the text: " + countDigits);
- foreach (KeyValuePair<char, int> pair in histogram)
- {
- if (pair.Value == 1)
- {
- Console.WriteLine("{0} occurred {1} time", pair.Key, pair.Value);
- }
- else
- {
- Console.WriteLine("{0} occurred {1} times", pair.Key, pair.Value);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment