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 ArraysAndLists
- {
- class Program
- {
- static void Main(string[] args)
- {
- SortedDictionary<string, long> phonebook = new SortedDictionary<string, long>();
- string[] input = Console.ReadLine().Split(new char[] { ' ', ':' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- while(input[0] != "Over")
- {
- string nameInput = String.Empty;
- long phoneNumber = 0;
- if (long.TryParse(input[0], out phoneNumber))
- {
- nameInput = input[1];
- phonebook[nameInput] = phoneNumber;
- }
- if (long.TryParse(input[1], out phoneNumber))
- {
- nameInput = input[0];
- phonebook[nameInput] = phoneNumber;
- }
- input = Console.ReadLine().Split(new char[] { ' ', ':' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
- }
- foreach(KeyValuePair<string,long> item in phonebook)
- {
- Console.WriteLine($"{item.Key} -> {item.Value}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment