using System.Collections.Generic;
using System.Text.RegularExpressions;
Dictionary<string, int> neibWords;
neibWords = new Dictionary<string, int>();
public void addNeibWord(string s)
if (!neibWords.ContainsKey(s))
public int getCountOfNeib(string s)
bool hasValue = neibWords.TryGetValue(s, out res);
if (hasValue) return res;
public HashSet<string> request(int n)
HashSet<string> res = new HashSet<string>();
foreach (string s in neibWords.Keys)
public static void Main()
Dictionary<string, Word> words = new Dictionary<string, Word>();
words.Add("", new Word(""));
using (StreamReader sr = new StreamReader("C:\\Users\\USER\\source\\repos\\Confirmit\\inputText.txt", Encoding.Default))
string[] strs = text.Split(new string[] { " ", ".", ",", "–", "!", "?", "*" }, StringSplitOptions.RemoveEmptyEntries);
string str = s1.ToLower();
if (!words.ContainsKey(str))
words[str].addNeibWord(last);
words[last].addNeibWord(str);
string st = Console.ReadLine();
int n = Convert.ToInt32(Console.ReadLine());
if (!words.ContainsKey(st))
Console.WriteLine("Такого слова нет!");
HashSet<string> ans = words[st].request(n);
if (ans.Equals(new HashSet<string>()))
Console.WriteLine("Нет подходящий слов!");
foreach (string str in ans)