Advertisement
Guest User

Mixed Phone problem

a guest
Mar 20th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _3.Mixed_Phones
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var inputLine = Console.ReadLine()
  14.                 .Split(' ');
  15.  
  16.             var resultDictionary = new SortedDictionary<string, int>();
  17.  
  18.             while (inputLine[0].ToLower()!="over")
  19.             {
  20.                 int intResult = 0;
  21.                 if (int.TryParse(inputLine[0],out intResult))
  22.                 {
  23.                     resultDictionary[inputLine[2]] = intResult;
  24.                 }
  25.                 else if (int.TryParse(inputLine[2],out intResult))
  26.                 {
  27.                     resultDictionary[inputLine[0]] = intResult;
  28.                 }
  29.  
  30.                 inputLine = Console.ReadLine()
  31.                     .Split(' ');
  32.             }
  33.  
  34.            
  35.             foreach (var kvp in resultDictionary)
  36.             {
  37.                 Console.WriteLine($"{kvp.Key} -> {kvp.Value}");
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement