Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class Program
- {
- static void Main()
- {
- Dictionary<string, List<string>> courses = new Dictionary<string, List<string>>();
- while (true)
- {
- string input = Console.ReadLine();
- if (input == "end")
- break;
- string[] inputParts = input.Split(" : ");
- string courseName = inputParts[0];
- string studentName = inputParts[1];
- if (!courses.ContainsKey(courseName))
- {
- courses.Add(courseName, new List<string>());
- }
- courses[courseName].Add(studentName);
- }
- foreach (var course in courses)
- {
- Console.WriteLine($"{course.Key}: {course.Value.Count}");
- foreach (var student in course.Value)
- {
- Console.WriteLine($"-- {student}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement