Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Защита_14_лабы
- {
- class Program
- {
- static void Main(string[] args)
- {
- StreamReader R = new StreamReader("in.txt");
- //string readString = R.ReadLine();
- List<string> Sentences = new List<string>();
- char[] punctuation = new char[] { '.', '!', '?' };
- string temp_String = "";
- //Console.WriteLine(Convert.ToString((char)R.Read()));
- while (!R.EndOfStream)
- {
- string readStr = Convert.ToString((char)R.Read());
- if (readStr == "\r")
- {
- temp_String += " ";
- R.Read();
- continue;
- }
- if (readStr.IndexOfAny(punctuation) == -1)
- {
- temp_String += readStr;
- }
- else
- {
- temp_String += readStr;
- Sentences.Add(temp_String);
- temp_String = "";
- }
- }
- //foreach (char symbol in readString)
- //{
- // if (symbol.ToString().IndexOfAny(punctuation) == -1)
- // {
- // temp_String += symbol;
- // }
- // else
- // {
- // temp_String += symbol;
- // Sentences.Add(temp_String);
- // temp_String = "";
- // }
- //}
- int numMaxSentences = 0;
- int lengthMaxSentences = 0;
- //string currentSentences;
- for (int i = 0; i < Sentences.Count; i++)
- {
- //currentSentences = Sentences[i];
- if (Sentences[i].Length > lengthMaxSentences)
- {
- numMaxSentences = i;
- lengthMaxSentences = Sentences[i].Length;
- }
- }
- Console.WriteLine($"Максимальное предложение: {Sentences[numMaxSentences]}");
- Console.WriteLine($"Номер максимального предложения: {numMaxSentences + 1}");
- Console.WriteLine($"Длина максимального предложения: {lengthMaxSentences}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement