Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _06Courses
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. var cousesCount = new Dictionary<string, int>();
  12. var students = new Dictionary<string, List<string>>();
  13.  
  14. string command = string.Empty;
  15.  
  16. while ((command = Console.ReadLine()) != "end")
  17. {
  18. var input = command.Split(" : ").ToArray();
  19. string courseName = input[0];
  20. string studentName = input[1];
  21.  
  22. if (!students.ContainsKey(courseName))
  23. {
  24. students[courseName] = new List<string>();
  25. students[courseName].Add(studentName);
  26. cousesCount[courseName] = 1;
  27. }
  28. else if(!students[courseName].Contains(studentName))
  29. {
  30. students[courseName].Add(studentName);
  31. cousesCount[courseName] += 1;
  32. }
  33. }
  34.  
  35. foreach (var kvp in cousesCount)
  36. {
  37. Console.WriteLine($"{kvp.Key}: {kvp.Value}");
  38.  
  39. foreach (var student in students)
  40. {
  41. Console.WriteLine($"-- {student.Value}");
  42. }
  43. }
  44.  
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement