Advertisement
plamen27

Srubsko Unleashed

Dec 17th, 2016
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. class Program
  7. {
  8. static void Main()
  9. {
  10. Dictionary<string, Dictionary<string, int>> dict = new Dictionary<string, Dictionary<string, int>>();
  11. string pattern = @"^([A-Za-z]+\s*[A-Za-z]+\s*[A-Za-z]+)\s@([A-Za-z]+\s*[A-Za-z]+\s*[A-Za-z]+)\s([0-9]+)\s([0-9]+)$";
  12. string input = Console.ReadLine();
  13. while (input != "End")
  14. {
  15. Match match = Regex.Match(input, pattern);
  16. if (match.Success)
  17. {
  18. string singer = match.Groups[1].Value;
  19. string venue = match.Groups[2].Value;
  20. int ticketPrice = int.Parse(match.Groups[3].Value);
  21. int ticketCount = int.Parse(match.Groups[4].Value);
  22.  
  23. if (!dict.ContainsKey(venue))
  24. {
  25. dict.Add(venue, new Dictionary<string, int>());
  26. }
  27. if (!dict[venue].ContainsKey(singer))
  28. {
  29. dict[venue].Add(singer, 0);
  30. }
  31. dict[venue][singer] += ticketPrice * ticketCount;
  32. }
  33. input = Console.ReadLine();
  34. }
  35. foreach (var item in dict)
  36. {
  37. Console.WriteLine(item.Key);
  38. foreach (var singer in item.Value.OrderByDescending(a => a.Value))
  39. {
  40. Console.WriteLine($"# {singer.Key} -> {singer.Value}");
  41. }
  42. }
  43.  
  44. }// end clause
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement