Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text.RegularExpressions;
  4. using System.Linq;
  5.  
  6. namespace Courses
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             var inputType = new Dictionary<string, List<string>>();
  13.  
  14.             while (true)
  15.             {
  16.                 List<string> command = Console.ReadLine().Split(" : ").ToList();
  17.                 if (command[0] == "end")
  18.                 {
  19.                     break;
  20.                 }
  21.  
  22.                 if (!inputType.ContainsKey(command[0]))
  23.                 {
  24.                     inputType.Add(command[0], new List<string>());
  25.                     inputType[command[0]].Add(command[1]);
  26.                 }
  27.                 else
  28.                 {
  29.                     inputType[command[0]].Add(command[1]);
  30.                 }
  31.             }
  32.             foreach (var item in inputType.OrderByDescending(x => x.Value.Count))
  33.             {
  34.  
  35.                 Console.WriteLine($"{item.Key}: {item.Value.Count}");
  36.                 //var list = item.Value;
  37.  
  38.                 foreach (var kvp in item.Value.OrderBy(n => n))
  39.                 {
  40.                     Console.WriteLine($"-- {kvp}");
  41.                 }
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement