From b1f37e7fae7e89bef0c6d79e64860011ca04060e Mon Sep 17 00:00:00 2001 From: idkWhatUserNameToUse Date: Fri, 12 May 2023 13:09:47 +0300 Subject: [PATCH] fixed lab3 --- Lab3/Lab3/Lab3/Program.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lab3/Lab3/Lab3/Program.cs b/Lab3/Lab3/Lab3/Program.cs index 52cc432..70987ac 100644 --- a/Lab3/Lab3/Lab3/Program.cs +++ b/Lab3/Lab3/Lab3/Program.cs @@ -15,17 +15,17 @@ class Lab3 int[] amountOfWords = new int[textSplit.Length]; for (int i = 0; i < textSplit.Length; i++) { - string[] words = textSplit[i].Trim().Split(' '); + string[] words = textSplit[i].Trim().Split(' ', StringSplitOptions.RemoveEmptyEntries); amountOfWords[i] = words.Length; } // створюємо Dictionary, де ключ - кількість слів у реченні, а значення - речення - Dictionary sentenceDictionary = new Dictionary(); + Dictionary sentenceDictionary = new Dictionary(); for (int i = 0; i < textSplit.Length; i++) { - sentenceDictionary.Add(amountOfWords[i], textSplit[i]); + sentenceDictionary.Add(textSplit[i],amountOfWords[i] ); } - var sortedDict = sentenceDictionary.OrderBy(x => x.Key).ToDictionary(x => x.Value, x => x.Key); + var sortedDict = sentenceDictionary.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); Console.WriteLine(String.Join(";", sortedDict.Keys));