Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- class Program
- {
- static void Main()
- {
- Dictionary<string, Dictionary<string, int>> dict = new Dictionary<string, Dictionary<string, int>>();
- 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]+)$";
- string input = Console.ReadLine();
- while (input != "End")
- {
- Match match = Regex.Match(input, pattern);
- if (match.Success)
- {
- string singer = match.Groups[1].Value;
- string venue = match.Groups[2].Value;
- int ticketPrice = int.Parse(match.Groups[3].Value);
- int ticketCount = int.Parse(match.Groups[4].Value);
- if (!dict.ContainsKey(venue))
- {
- dict.Add(venue, new Dictionary<string, int>());
- }
- if (!dict[venue].ContainsKey(singer))
- {
- dict[venue].Add(singer, 0);
- }
- dict[venue][singer] += ticketPrice * ticketCount;
- }
- input = Console.ReadLine();
- }
- foreach (var item in dict)
- {
- Console.WriteLine(item.Key);
- foreach (var singer in item.Value.OrderByDescending(a => a.Value))
- {
- Console.WriteLine($"# {singer.Key} -> {singer.Value}");
- }
- }
- }// end clause
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement