Advertisement
desislava_topuzakova

03. Find Words

Mar 28th, 2021
1,160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Arrays
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             List<string> specialWords = new List<string>();
  12.             List<string> otherWords = new List<string>();
  13.  
  14.             int countWords = int.Parse(Console.ReadLine());
  15.  
  16.             for (int count = 1; count <= countWords; count++)
  17.             {
  18.                 string word = Console.ReadLine();
  19.  
  20.                 //проверка дали е специална
  21.                 if((word[0] >= 'A' && word[0] <= 'Z') && (word.Contains('i') || word.Contains('I')) && word.Length > 7)
  22.                 {
  23.                     //специална дума
  24.                     specialWords.Add(word);
  25.                 }
  26.                 else
  27.                 {
  28.                     //не е специална
  29.                     otherWords.Add(word);
  30.                 }
  31.             }
  32.  
  33.             Console.WriteLine("Special words: " + string.Join(", ", specialWords));
  34.             Console.WriteLine("Other words: " + string.Join(", ", otherWords));
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.         }        
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement