Advertisement
Guest User

Untitled

a guest
Oct 18th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 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. var name = input[1];
  28. if (contacts.ContainsKey(input[1]))
  29. {
  30. Console.WriteLine($"{name} -> {contacts[name]}");
  31. }
  32. else
  33. {
  34. Console.WriteLine($"Contact {name} does not exist.");
  35. }
  36. }
  37. if (input[0] == "END")
  38. return;
  39. }
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement