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 _03_MixedPhones
- {
- class MixedPhones
- {
- static void Main(string[] args)
- {
- var result = new SortedDictionary<string, long>();
- string inputStr = Console.ReadLine();
- while (inputStr != "Over")
- {
- var input = inputStr
- .Split(
- new[] {' '},
- StringSplitOptions.RemoveEmptyEntries);
- long phoneNumber;
- long.TryParse(input[0], out phoneNumber);
- if (phoneNumber != 0)
- {
- result.Add(input[2].Trim(), phoneNumber);
- }
- else
- {
- result.Add(input[0].Trim(), long.Parse(input[2]));
- }
- inputStr = Console.ReadLine();
- }
- foreach (var kvp in result.Keys)
- {
- Console.WriteLine($"{kvp} -> {result[kvp]}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment