Advertisement
Guest User

Untitled

a guest
May 10th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 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 phonebook.upgradeЯ
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. string[] numbers = Console.ReadLine().Split(' ').ToArray();
  15.  
  16. SortedDictionary<string, string> phoneBook = new SortedDictionary<string, string>();
  17.  
  18. string command = numbers[0];
  19. while (command != "END")
  20. {
  21. if (command == "A")
  22. {
  23. phoneBook[numbers[1]] = numbers[2];
  24. }
  25. else if (command == "S")
  26. {
  27. if (phoneBook.ContainsKey(numbers[1]))
  28. {
  29. Console.WriteLine($"{numbers[1]} -> {phoneBook[numbers[1]]}");
  30. }
  31. else
  32. {
  33. Console.WriteLine($"Contact {numbers[1]} does not exist.");
  34. }
  35. }
  36. else if (command == "ListAll")
  37. {
  38. foreach (var entry in phoneBook)
  39. {
  40. Console.WriteLine($"{entry.Key} -> {entry.Value}");
  41. }
  42.  
  43. }
  44. numbers = Console.ReadLine()
  45. .Split(' ')
  46. .ToArray();
  47. command = numbers[0];
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement