Advertisement
svetlyoek

Untitled

Mar 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 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. List<string> names = new List<string>();
  13. Dictionary<string,List<string> > modules= new Dictionary<string, List<string>>();
  14. while((command=Console.ReadLine())!="end")
  15. {
  16. string[] text = command.Split(" : ").ToArray();
  17. string module = text[0];
  18. string name = text[1];
  19. if(!modules.ContainsKey(module))
  20. {
  21. modules.Add(module,names);
  22. names.Add(name);
  23. names = new List<string>();
  24.  
  25. }
  26. else
  27. {
  28. modules[module].Add(name);
  29. }
  30.  
  31. }
  32. foreach (var item in modules.OrderByDescending(x => x.Value.Count))
  33. {
  34. Console.WriteLine($"{item.Key}: {item.Value.Count}");
  35.  
  36. foreach(var kvp in item.Value.OrderBy(x=>x))
  37. {
  38. Console.WriteLine($"-- {kvp}");
  39. }
  40.  
  41. }
  42.  
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement