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 ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- var phonebook = new Dictionary<string, string>();
- while (true)
- {
- string[] splitedInput = Console.ReadLine().Split();
- if (splitedInput[0] == "End")
- {
- break;
- }
- if (splitedInput[0] == "A")
- {
- if (phonebook.ContainsKey(splitedInput[1]))
- {
- phonebook[splitedInput[1]] = splitedInput[2];
- }
- else
- {
- phonebook.Add(splitedInput[1], splitedInput[2]);
- }
- }
- else if (splitedInput[0] == "S")
- {
- if (phonebook.ContainsKey(splitedInput[1]))
- {
- Console.WriteLine($"{splitedInput[1]} -> {phonebook[splitedInput[1]]}");
- }
- else Console.WriteLine($"Contact {splitedInput[1]} does not exist.");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement