Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace courses
- {
- class Program
- {
- static void Main()
- {
- string command = Console.ReadLine();
- var coursesList = new Dictionary<string, List<string>>();
- while (command!="end")
- {
- List<string> commandInput = command.Split(" : ").ToList();
- string courseName = commandInput[0];
- string studentName = commandInput[1];
- if (!coursesList.ContainsKey(courseName))
- {
- coursesList[courseName] = new List<string>();
- }
- coursesList[courseName].Add(studentName);
- command = Console.ReadLine();
- }
- coursesList.OrderBy(x => x.Value.Count);
- foreach (var course in coursesList)
- {
- course.Value.Sort();
- int studentsCount = course.Value.Count;
- Console.WriteLine($"{course.Key}: {studentsCount}");
- for (int i = 0; i < course.Value.Count; i++)
- {
- Console.WriteLine($"-- {course.Value[i]}");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement