Advertisement
Guest User

Untitled

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