Anonim_999

asd

Dec 3rd, 2022 (edited)
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using System.Linq;
  5.  
  6. namespace ConsoleApp26
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string simbol;
  13.             List<string> text;
  14.             char[] separator = { ' ', '.', ',' };
  15.  
  16.             if (args.Length > 0)
  17.             {
  18.                 text = args[0].Split(separator).ToList();
  19.                 Console.Write("Текст: ");
  20.  
  21.                 foreach (string item in text)
  22.                 {
  23.                     Console.Write(item + " ");
  24.                 }
  25.                 Console.WriteLine();
  26.                 simbol = args.Last();
  27.                 Console.WriteLine($"буква: {simbol}");
  28.                 Console.Write("Результат: ");
  29.  
  30.                 foreach (string word in text)
  31.                 {
  32.                     if (word.ToLower().StartsWith(simbol))
  33.                     {
  34.                         Console.Write(word.Replace(",","").Replace(".","") + " ");
  35.                     }
  36.                 }
  37.             }
  38.             else
  39.             {
  40.                 Console.WriteLine("Отсуствуют аргменты");
  41.             }
  42.             Console.ReadKey();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment