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