Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Phonebook
- {
- class Program
- {
- static Dictionary<string, string> phonebook = new Dictionary<string, string>();
- static void Main()
- {
- string arr = Console.ReadLine();
- List<string> arrInput = arr.Trim().Split(' ').ToList();
- while (arr!="END")
- {
- arrInput = arr.Trim().Split(' ').ToList();
- if (arrInput[0].Equals("A"))
- {
- if (phonebook.ContainsKey(arrInput[1]))
- {
- phonebook[arrInput[1]] = arrInput[2];
- }
- else
- {
- phonebook.Add(arrInput[1], arrInput[2]);
- }
- }
- if (arrInput[0].Equals("S"))
- {
- if (phonebook.ContainsKey(arrInput[1]))
- {
- Console.WriteLine("{0} -> {1}", arrInput[1], phonebook[arrInput[1]]);
- }
- else
- {
- Console.WriteLine("Contact {0} does not exist.", arrInput[1]);
- }
- }
- arr = Console.ReadLine();
- if (arr == "END")
- {
- break;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement