using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace ConsoleApp3 { class Program { static void Main(string[] args) { int[] Digits = new int[33]; string[] StringDigits; string TempString = ""; int count; int StringCounter = 0; int StringNumber = 1; bool Found = false; StreamReader File = new StreamReader("txt.txt"); TempString = File.ReadLine(); while (TempString!=null) { Found = false; StringDigits = TempString.Split(' '); count = 0; for(int i = 0; i < StringDigits.Count() - 3; i++) { count = 0; for (int j = i+3; j < StringDigits.Count() - 3; j++) { if (StringDigits[i] == StringDigits[j] && StringDigits[i + 1] == StringDigits[j + 1] && StringDigits[i + 2] == StringDigits[j + 2]) count++ ; } if (count > 0) { Console.WriteLine("In string " + StringNumber.ToString() + " found " + StringDigits[i] + StringDigits[i + 1] + StringDigits[i + 2] + " " + count.ToString() + " times"); Found = true; } } if (Found) { Console.WriteLine("In string " + StringNumber.ToString() + " founded mathes "); StringCounter++; } StringNumber++; TempString = File.ReadLine(); } Console.WriteLine("Total strings = " + StringCounter.ToString()); Console.ReadLine(); File.Close(); } } }