Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace _6.Courses
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, List<string>> students = new Dictionary<string, List<string>>();
- while (true)
- {
- var input = Console.ReadLine().Split(" : ").ToArray();
- if (input[0] == "end")
- {
- break;
- }
- if (!students.ContainsKey(input[0]))
- {
- students.Add(input[0], new List<string>());
- students[input[0]].Add(input[1]);
- }
- else
- {
- students[input[0]].Add(input[1]);
- }
- }
- students = students
- .OrderByDescending(x => x.Value.Count)
- .ThenBy(x => x.Value)
- .ToDictionary(x => x.Key, x => x.Value);
- foreach (var kvp in students)
- {
- Console.WriteLine($"{kvp.Key}: {kvp.Value.Count}");
- var list = kvp.Value;
- foreach (var kvp2 in list)
- {
- Console.WriteLine($"-- {kvp2}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement