Advertisement
YavorGrancharov

Mixed_Phones(60%)

Jul 8th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace Mixed_Phones
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             string[] input = Console.ReadLine().Split().ToArray();
  12.             Dictionary<string, string> output = new Dictionary<string, string>();
  13.  
  14.             while (input[0] != "Over")
  15.             {
  16.                 string name = input[0];
  17.                 string number = input[2];
  18.                 long value = 0;
  19.  
  20.                 if (long.TryParse(number, out value))
  21.                 {
  22.                     output[name] = number;
  23.                 }
  24.                 else if (long.TryParse(name, out value))
  25.                 {
  26.                     output[number] = name;
  27.                 }
  28.                 input = Console.ReadLine().Split().ToArray();
  29.             }
  30.             var list = output.Keys.ToList();
  31.             list.Sort();
  32.             foreach (var x in list)
  33.             {
  34.                 Console.WriteLine("{0} -> {1}", x, output[x].TrimStart('0'));
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement