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.upgradeЯ
- {
- class Program
- {
- static void Main(string[] args)
- {
- string[] numbers = Console.ReadLine().Split(' ').ToArray();
- SortedDictionary<string, string> phoneBook = new SortedDictionary<string, string>();
- string command = numbers[0];
- while (command != "END")
- {
- if (command == "A")
- {
- phoneBook[numbers[1]] = numbers[2];
- }
- else if (command == "S")
- {
- if (phoneBook.ContainsKey(numbers[1]))
- {
- Console.WriteLine($"{numbers[1]} -> {phoneBook[numbers[1]]}");
- }
- else
- {
- Console.WriteLine($"Contact {numbers[1]} does not exist.");
- }
- }
- else if (command == "ListAll")
- {
- foreach (var entry in phoneBook)
- {
- Console.WriteLine($"{entry.Key} -> {entry.Value}");
- }
- }
- numbers = Console.ReadLine()
- .Split(' ')
- .ToArray();
- command = numbers[0];
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement