Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace ConsoleApp1
  9. {
  10. class Program
  11. {
  12.  
  13. static void Main(string[] args)
  14. {
  15. var phonebook = new Dictionary<string, string>();
  16.  
  17.  
  18. while (true)
  19. {
  20. string[] splitedInput = Console.ReadLine().Split();
  21. if (splitedInput[0] == "End")
  22. {
  23. break;
  24. }
  25.  
  26. if (splitedInput[0] == "A")
  27. {
  28. if (phonebook.ContainsKey(splitedInput[1]))
  29. {
  30. phonebook[splitedInput[1]] = splitedInput[2];
  31. }
  32. else
  33. {
  34. phonebook.Add(splitedInput[1], splitedInput[2]);
  35.  
  36. }
  37. }
  38. else if (splitedInput[0] == "S")
  39. {
  40. if (phonebook.ContainsKey(splitedInput[1]))
  41. {
  42. Console.WriteLine($"{splitedInput[1]} -> {phonebook[splitedInput[1]]}");
  43. }
  44. else Console.WriteLine($"Contact {splitedInput[1]} does not exist.");
  45. }
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement