Advertisement
why_where_what

02.Key-Key,Value-Value

Jul 12th, 2017
402
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 _02.KeyKeyValueValue
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string keyToSearch = Console.ReadLine();
  14.             string valueToSearch = Console.ReadLine();
  15.             int n = int.Parse(Console.ReadLine());
  16.            
  17.             for (int i = 0; i < n; i++)
  18.             {
  19.                 string[] tokens = Console.ReadLine()
  20.                     .Split(new string[] {" => "}, StringSplitOptions.RemoveEmptyEntries);
  21.  
  22.                 string key = tokens[0];
  23.                 string[] values = tokens[1].Split(';');
  24.  
  25.                 if (key.Contains(keyToSearch))
  26.                 {
  27.                     Console.WriteLine($"{key}:");
  28.                     for (int j = 0; j < values.Length; j++)
  29.                     {
  30.                         if (values[j].Contains(valueToSearch))
  31.                         {
  32.                             Console.WriteLine($"-{values[j]}");
  33.                         }
  34.                     }
  35.                 }
  36.                
  37.             }
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement