Advertisement
ivanov_ivan

Phonebook

Oct 13th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.19 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 FuckingDotNot
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Dictionary<string, string> phoneBook = new Dictionary<string, string>();
  14.  
  15.             string input = Console.ReadLine();
  16.  
  17.             while (input != "END")
  18.             {
  19.                 string[] inputParameters = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  20.  
  21.                 if (inputParameters[0] == "A")
  22.                 {
  23.                     phoneBook[inputParameters[1]] = inputParameters[2];
  24.                 }
  25.                 else
  26.                 {
  27.                     if (!phoneBook.ContainsKey(inputParameters[1]))
  28.                     {
  29.                         Console.WriteLine($"Contact {inputParameters[1]} does not exist.");
  30.                     }
  31.                     else
  32.                     {
  33.                         Console.WriteLine($"{inputParameters[1]} -> {phoneBook[inputParameters[1]]}");
  34.                     }
  35.                 }
  36.  
  37.                 input = Console.ReadLine();
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement