Advertisement
Guest User

Untitled

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