告诉我如何解决问题?您需要计算该行中每个字母的重复次数。我编写了以下代码,但它生成了整行。我不知道如何将其分解为符号并将其与含义一起添加到字典中。
Dictionary<string, int> letterDictionary = new Dictionary<string, int>();
string text;
string textLow;
string textFormat;
int count = 0;
Console.WriteLine("Введите текст: ");
text = Console.ReadLine();
textLow = text.ToLower();
textFormat = textLow.Replace(" ", "").Replace(",", "").Replace("!", "");
for (int i = 0; i < textFormat.Length; i++)
{
if (textFormat[0] == textFormat[i])
{
count++;
}
}
letterDictionary.Add(textFormat, count);
foreach (var pair in letterDictionary)
{
Console.WriteLine($"Буква: {pair.Key}, повторений: {pair.Value}");
}
