VitalyD

Untitled

Jan 21st, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.IO;
  3. using System.Text;
  4.  
  5. namespace ConsoleApp10
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             string[] lines = File.ReadAllLines("dictionary.txt");
  12.             HashSet<string> dictionary = new HashSet<string>(lines);
  13.  
  14.             IEnumerator<string> data;
  15.             data = File.ReadLines("text.txt").GetEnumerator();
  16.  
  17.             var html = new FileStream("ansver.html", FileMode.Create);
  18.  
  19.             Hz(dictionary, data);
  20.  
  21.         }
  22.  
  23.         public static IEnumerable<string> Hz(HashSet<string> dictionary, IEnumerator<string> data)
  24.         {
  25.             while (data.MoveNext())
  26.             {
  27.                 if (data.Current != null)
  28.                     foreach (string word in data.Current.Split(' '))
  29.                     {
  30.                         if (dictionary.Contains(word))
  31.                         {
  32.                             yield return "<b><i>" + word + "</i></b>";
  33.                         }
  34.                     }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment