diff --git a/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/Dima.csproj b/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/Dima.csproj new file mode 100644 index 0000000..ed9781c --- /dev/null +++ b/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/Dima.csproj @@ -0,0 +1,10 @@ + + + + Exe + net10.0 + enable + enable + + + diff --git a/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/Program.cs b/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/Program.cs new file mode 100644 index 0000000..6c6fe8f --- /dev/null +++ b/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/Program.cs @@ -0,0 +1,37 @@ +namespace Lab1; +class Program{ + static void Main(string[] args){ + string filePath = "input.txt"; + string originalText = ReadFromFile(filePath); + Console.WriteLine("=== Исходный текст из файла ==="); + Console.WriteLine(originalText); + Console.WriteLine("\n=== Обработанный текст ==="); + Console.WriteLine(ProcessText(originalText)); + } + static string ProcessText(string text) + { + var resultBuilder = new System.Text.StringBuilder(); + for (int i = 0; i < text.Length - 1; i++) + { + if (text[i] == ' ' && text[i + 1] == '-') + { + int startIndex = i; + int endIndex = i; + while (endIndex < text.Length && text[endIndex] != '.' && text[endIndex] != '!' && text[endIndex] != '?') + { + endIndex++; + } + + resultBuilder.Append(text, startIndex, endIndex - startIndex); + i = endIndex - 1; + } + } + return " " + resultBuilder.ToString(); + } + + + static string ReadFromFile(string filepath) + { + return File.ReadAllText(filepath); + } +} \ No newline at end of file diff --git a/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/input.txt b/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/input.txt new file mode 100644 index 0000000..a981168 --- /dev/null +++ b/Files/2-nd course/4-th semester/Object-oriented programming/Laboratory work/Lab #1/Dima/input.txt @@ -0,0 +1,4 @@ +fasfdasf - asfsaasfafsfsa. +asfasfasf - asfasfafsfsa. +afsrehgre fwef ewfwefwef. +fewefwe - wef wef wef. \ No newline at end of file