Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Disclaimer: The creator of 'C# Shell (C# Offline Compiler)' is in no way responsible for the code posted by any user.
- using System;
- using System.IO;
- using System.Linq;
- using System.Collections.Generic;
- namespace CSharp_Shell
- {
- public static class Program
- {
- public static void Main()
- {
- var courses = new Dictionary<string, List<string>>();
- var registeredStudents = 0;
- while (true)
- {
- var input = Console.ReadLine();
- if(input == "end")
- {
- break;
- }
- var items = input.Split(":");
- var courseName = items[0];
- var studentName = items[1];
- if(!courses.ContainsKey(courseName))
- {
- courses[courseName] = new List<string>();
- }
- courses[courseName].Add(studentName);
- }
- foreach(var kvp in courses.OrderByDescending(x=>x.Value.Count).ThenBy(x=>x.Key))
- {
- Console.WriteLine($"{kvp.Key} : {string.Join(string.Empty, kvp.Value.Count)}");
- Console.WriteLine($"-- {string.Join(string.Empty, kvp.Value)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement