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