Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _04._Snowwhite
  6. {
  7.     class Snowwhite
  8.     {
  9.         static void Main()
  10.         }
  11.             Dictionary<string, int> dwarfs = new Dictionary<string, int>();
  12.             string input = string.Empty;
  13.  
  14.             while ((input = Console.ReadLine()) != "Once upon a time")
  15.             {
  16.                 string[] args = input.Split(new[] {' ', '<', ':', '>' }, StringSplitOptions.RemoveEmptyEntries);
  17.  
  18.                 string name = "("+args[1]+")"+ " "+args[0];
  19.                 int physics = int.Parse(args[2]);
  20.  
  21.                 if (!dwarfs.ContainsKey(name))
  22.                 {
  23.                     dwarfs.Add(name,0);
  24.                 }
  25.                 dwarfs[name]=physics;
  26.             }
  27.  
  28.             foreach (var dwarf in dwarfs.OrderByDescending(x=>x.Value).ThenByDescending(x=>x.Key.Count()))
  29.             {
  30.                   Console.WriteLine($"{dwarf.Key} <-> {dwarf.Value}");
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement