Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace mid_exam
- {
- class Program
- {
- static void Main(string[] args)
- {
- var command = Console.ReadLine().Split(" : ").ToArray();
- var courses = new Dictionary<string, List<string>>();
- while (command[0] != "end")
- {
- if (!courses.ContainsKey(command[0]))
- {
- courses.Add(command[0], new List<string>());
- }
- courses[command[0]].Add(command[1]);
- command = Console.ReadLine().Split(" : ").ToArray();
- }
- foreach (var course in courses.OrderByDescending(x => x.Value.Count))
- {
- Console.WriteLine("{0}: {1}", course.Key, course.Value.Count);
- foreach (var name in course.Value.OrderBy(n => n))
- {
- Console.WriteLine("-- {0}", name);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement