Guest User

Untitled

a guest
Jul 13th, 2017
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1.     using System;
  2.     using System.Collections.Generic;
  3.     using System.Linq;
  4.     using System.Text;
  5.     using System.Threading.Tasks;
  6.  
  7. namespace _5._2.KeyKeyValueValue
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string searchedKey = Console.ReadLine();
  14.             string searchedValue = Console.ReadLine();
  15.             int n = int.Parse(Console.ReadLine());
  16.            
  17.  
  18.             for (int i = 0; i < n; i++)
  19.             {
  20.                 string[] tokens = Console.ReadLine().Split(new string[] { " => " }, StringSplitOptions.RemoveEmptyEntries);
  21.                 string mainWord = tokens[0];
  22.                 string[] minorWords = tokens[1].Split(';');
  23.  
  24.                 if (mainWord.Contains(searchedKey))
  25.                 {
  26.                     Console.WriteLine($"{mainWord}:");
  27.                     foreach (var minorWord in minorWords)
  28.                     {
  29.                         if (minorWord.Contains(searchedValue))
  30.                         {
  31.                             Console.WriteLine($"-{minorWord}");
  32.                         }
  33.                     }
  34.                 }
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment