Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1.  
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace courses
  9. {
  10. class Program
  11. {
  12. static void Main()
  13. {
  14. string command = Console.ReadLine();
  15. var coursesList = new Dictionary<string, List<string>>();
  16. while (command!="end")
  17. {
  18. List<string> commandInput = command.Split(" : ").ToList();
  19. string courseName = commandInput[0];
  20. string studentName = commandInput[1];
  21. if (!coursesList.ContainsKey(courseName))
  22. {
  23. coursesList[courseName] = new List<string>();
  24. }
  25. coursesList[courseName].Add(studentName);
  26. command = Console.ReadLine();
  27. }
  28. coursesList.OrderBy(x => x.Value.Count);
  29. foreach (var course in coursesList)
  30. {
  31. course.Value.Sort();
  32. int studentsCount = course.Value.Count;
  33. Console.WriteLine($"{course.Key}: {studentsCount}");
  34. for (int i = 0; i < course.Value.Count; i++)
  35. {
  36. Console.WriteLine($"-- {course.Value[i]}");
  37. }
  38. }
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement