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
- {
- public static void Main()
- {
- Dictionary<string, List<string>> courses = new Dictionary<string, List<string>>();
- string command;
- while ((command = Console.ReadLine()) != "end")
- {
- string[] current = command.Split(" : ");
- string course = current[0];
- string student = current[1];
- if (!courses.ContainsKey(course))
- {
- courses.Add(course, new List<string>());
- }
- courses[course].Add(student);
- }
- foreach (var course in courses)
- {
- Console.WriteLine($"{course.Key}: {course.Value.Count()}");
- Console.WriteLine($"-- {string.Join("\n-- ", course.Value)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement