Aliendreamer

hackwarsday8-diactionaries

May 22nd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 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 hackwarsDay8
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int entries = int.Parse(Console.ReadLine());
  15.  
  16.             Dictionary<string, int> phoneBook = new Dictionary<string, int>();
  17.  
  18.             for (int i = 0; i < entries; i++)
  19.             {
  20.                 string[] data = Console.ReadLine().Split(' ');
  21.  
  22.                 phoneBook.Add(data[0], Convert.ToInt32(data[1]));
  23.             }
  24.  
  25.             string name;
  26.             while ((name = Console.ReadLine()) != null)
  27.             {
  28.                 if (phoneBook.ContainsKey(name))
  29.                     Console.WriteLine(name + "=" + phoneBook[name]);
  30.                 else
  31.                     Console.WriteLine("Not found");
  32.             }
  33.  
  34.  
  35.        
  36.         }
  37.     }
  38. }
Add Comment
Please, Sign In to add comment