BonchoBelutov

Extract sentences

May 22nd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4.  
  5. namespace ExctractSentence2
  6. {
  7.     class ExctractSentence2
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var keyWord = Console.ReadLine();
  12.             var text = Console.ReadLine();
  13.             var original = text.Split('.');
  14.             var result = new StringBuilder();
  15.             for (int i = 0; i < text.Length; i++)
  16.             {
  17.                 if (text[i] == '.')
  18.                 {
  19.                     result.Append(".");
  20.                 }
  21.                 else if (char.IsLetter(text[i]))
  22.                 {
  23.                     result.Append(text[i]);
  24.                 }
  25.                 else
  26.                 {
  27.                     result.Append(" ");
  28.                 }
  29.             }
  30.             var answer = result.ToString().ToLower().Split('.');
  31.             for (int j = 0; j < answer.Length; j++)
  32.             {
  33.                 var tmpAnswer = answer[j].Split();
  34.                 for (int i = 0; i < tmpAnswer.Length; i++)
  35.                 {
  36.                     if (tmpAnswer[i] == keyWord.ToLower())
  37.                     {
  38.                         Console.Write(original[j] + ".");
  39.                     }
  40.                 }
  41.             }
  42.             Console.WriteLine();
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment