Advertisement
svetlyoek

Untitled

Mar 17th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp206
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string command = string.Empty;
  12. SortedDictionary<string, List<string>> dict = new SortedDictionary<string, List<string>>();
  13. while ((command = Console.ReadLine()) != "End")
  14. {
  15. string[] text = command.Split(" -> ").ToArray();
  16. string companyName = text[0];
  17. string employee = text[1];
  18. if (!dict.ContainsKey(companyName))
  19. {
  20. dict.Add(companyName, new List<string>());
  21. dict[companyName].Add(employee);
  22. }
  23. else
  24. {
  25. dict[companyName].Add(employee);
  26. }
  27. }
  28. foreach(var item in dict)
  29. {
  30. Console.WriteLine($"{item.Key}");
  31. foreach(var element in item.Value.Distinct())
  32. {
  33.  
  34. Console.WriteLine($"-- {element}");
  35. }
  36. }
  37.  
  38. }
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement