Загрузка данных


using System;
using System.Collections.Generic;
using System.Linq;

namespace SymbolCounterConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Введите текст для анализа (нажмите Enter для завершения):");
            string input = Console.ReadLine();
            
            if (string.IsNullOrWhiteSpace(input))
            {
                Console.WriteLine("Текст не введен!");
                return;
            }
            
            var charCount = new Dictionary<char, int>();
            
            foreach (char c in input)
            {
                if (char.IsWhiteSpace(c)) continue; // Пропускаем пробелы
                
                if (charCount.ContainsKey(c))
                    charCount[c]++;
                else
                    charCount[c] = 1;
            }
            
            Console.WriteLine($"\nВсего символов (без пробелов): {charCount.Sum(x => x.Value)}");
            Console.WriteLine($"Уникальных символов: {charCount.Count}\n");
            
            Console.WriteLine("Статистика по символам:");
            foreach (var item in charCount.OrderByDescending(x => x.Value))
            {
                double percentage = (double)item.Value / charCount.Sum(x => x.Value) * 100;
                Console.WriteLine($"{item.Key} : {item.Value} раз ({percentage:F1}%)");
                
                // Простая текстовая диаграмма
                int barLength = (int)(percentage / 2);
                Console.Write(new string('█', barLength));
                Console.WriteLine($" {percentage:F1}%");
            }
            
            Console.WriteLine("\nНажмите любую клавишу для выхода...");
            Console.ReadKey();
        }
    }
}