Advertisement
NadyaMisheva

dobavyane na ychenici

Mar 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. public class Program
  5. {
  6. public static void Main()
  7. {
  8. Dictionary<string, List<string>> school = new Dictionary<string, List<string>> ();
  9. while(true)
  10. {
  11. string[] command = Console.ReadLine().Split(' ');
  12. if (command[0] == "End")
  13. {
  14. break;
  15. }
  16. else if (command[0] == "Add")
  17. {
  18. string student = command[1];
  19. string paralelka = command[2];
  20. if(school.ContainsKey(paralelka))
  21. {
  22. school[paralelka].Add(student);
  23. }
  24. else
  25. {
  26. List<string> newParalelka = new List<string>();
  27. newParalelka.Add(student);
  28. school[paralelka] = newParalelka;
  29. }
  30. }
  31. }
  32. foreach(string paralelka in school.Keys)
  33. {
  34. Console.WriteLine("Class name: " + paralelka);
  35. foreach(string student in school[paralelka])
  36. {
  37. Console.WriteLine("###" + student);
  38. }
  39. }
  40.  
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement