Advertisement
vencinachev

SpecialWords

Mar 13th, 2022
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Lists
  6. {
  7.     class Program
  8.     {
  9.         static bool ContainsE(string text)
  10.         {
  11.             foreach (var item in text)
  12.             {
  13.                 if (item == 'e')
  14.                 {
  15.                     return true;
  16.                 }
  17.             }
  18.             return false;
  19.         }
  20.         static void Main(string[] args)
  21.         {
  22.             int n = int.Parse(Console.ReadLine());
  23.             List<string> special = new List<string>();
  24.             List<string> other = new List<string>();
  25.             for (int i = 0; i < n; i++)
  26.             {
  27.                 string word = Console.ReadLine();
  28.                 if (word[0] != word[word.Length - 1]
  29.                     && ContainsE(word)
  30.                     && word.Length > 5)
  31.                 {
  32.                     special.Add(word);
  33.                 }
  34.                 else
  35.                 {
  36.                     other.Add(word);
  37.                 }
  38.             }
  39.             Console.WriteLine($"Special words: {string.Join(",", special)}");
  40.             Console.WriteLine($"Other words: {string.Join(",", other)}");
  41.         }
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement