using System; using System.Collections.Generic; using System.Linq; namespace ZnanijaCSharp { class Program { static void Main(string[] args) { Console.Title = "Task"; string strOne = Console.ReadLine(), strTwo = Console.ReadLine(); char symbol = char.Parse(Console.ReadLine()); uint value = 0; List arr = new List(); if(strOne.Length > 100 && strTwo.Length > 100) { Environment.Exit(1); } addToArray(strOne, ref arr); arr = getResult(ref arr, ref value, symbol); outPutArr(ref arr); value = 0; addToArray(strTwo, ref arr); arr = getResult(ref arr, ref value, symbol); outPutArr(ref arr); Console.ReadKey(); } static void addToArray(string str, ref List arr) { arr = str.Split(' ').ToList(); } static List getResult(ref List arr, ref uint value, char symbol) { List arrNew = new List(); for (int i = 0; i < arr.Count; i++) { if (arr[i][0] == symbol && arr[i][arr[i].Length - 1] == symbol) { arrNew.Add(arr[i]); value++; } } Console.WriteLine("Количество слов: {0}", value); return arrNew; } static void outPutArr(ref List arr) { for (int i = 0; i < arr.Count; i++) { Console.WriteLine(arr[i]); } } } }