Задача 03. Forum Topics от Advanced Collections - Exercises,малко помощ..
Някъде бъркам с последната проверка и не мога да разбера къде..
Ето и кода...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _03.Forum_Topics
{
class Program
{
static void Main()
{
var output =new Dictionary<string,HashSet<string>>();
var input = Console.ReadLine();
while (input !="filter")
{
var outputLine = input.Split(new[] {'-', '>', ','}, StringSplitOptions.RemoveEmptyEntries);
var topic = outputLine[0];
if (!output.ContainsKey(topic))
{
output[topic]=new HashSet<string>();
}
for (int i = 1; i < outputLine.Length; i++)
{
output[topic].Add(outputLine[i]);
}
input = Console.ReadLine();
}
var filter = Console.ReadLine();
var filterWord = filter.Split(new []{',',' '},StringSplitOptions.RemoveEmptyEntries);
foreach (var key in output)
{
if (key.Value.Contains(filterWord[0]) || key.Value.Contains(filterWord[1]) )
{
Console.WriteLine("{0} | #{1}",key.Key, string.Join(", #",key.Value));
}
}
}
}
}