using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
Console.WriteLine("Введите текст:");
string text = Console.ReadLine() ?? string.Empty;
// 1. Общее количество символов
int totalChars = text.Length;
Console.WriteLine($"\nОбщее количество символов: {totalChars}");
// 2. Подсчёт частоты каждого символа
var charCounts = new Dictionary<char, int>();
foreach (char c in text)
{
if (charCounts.ContainsKey(c))
charCounts[c]++;
else
charCounts[c] = 1;
}
// 3. Вывод числограммы
Console.WriteLine("\nЧислограмма (частота каждого символа):");
foreach (var pair in charCounts.OrderBy(p => p.Key)) // сортировка по символу
{
char symbol = pair.Key;
int count = pair.Value;
string numeralGraph = new string('1', count); // строка из '1' длиной count
// Для наглядности символ заключается в кавычки (пробел тоже становится видимым)
Console.WriteLine($"'{symbol}' : {numeralGraph} (частота: {count})");
}
Console.WriteLine("\nНажмите любую клавишу для выхода...");
Console.ReadKey();
}
}