Advertisement
Guest User

Untitled

a guest
Oct 10th, 2016
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _10.Сръбско_Unleashed
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var VenuesIncome = new Dictionary<string, Dictionary<string, long>>();
  14.  
  15. while (true)
  16. {
  17. var inputedInfo = Console.ReadLine();
  18.  
  19. if (inputedInfo == "End")
  20. {
  21. break;
  22. }
  23.  
  24. var WholeInfoParts = inputedInfo.Split(new char[] { '@' }).ToArray();
  25.  
  26. //proverka dali sa tochno dumite
  27. if ((WholeInfoParts[0].Count(Char.IsWhiteSpace) == 0 ||
  28. WholeInfoParts[0].Count(Char.IsWhiteSpace) > 3) ||
  29. (WholeInfoParts[1].Count(Char.IsWhiteSpace) < 2 ||
  30. WholeInfoParts[1].Count(Char.IsWhiteSpace) > 4))
  31. {
  32. continue;
  33. }
  34.  
  35. string[] secondPartInfo = WholeInfoParts[1].Split().ToArray();
  36.  
  37. string venue = "";
  38. int ticketPrice = 0;
  39. int ticketsCount = 0;
  40. string singer = WholeInfoParts[0].Trim();
  41.  
  42. if (secondPartInfo.Length == 3)
  43. {
  44. venue = secondPartInfo[0];
  45. ticketPrice = int.Parse(secondPartInfo[1]);
  46. ticketsCount = int.Parse(secondPartInfo[2]);
  47. }
  48. else if (secondPartInfo.Length == 4)
  49. {
  50. venue = secondPartInfo[0] + " " + secondPartInfo[1];
  51. ticketPrice = int.Parse(secondPartInfo[2]);
  52. ticketsCount = int.Parse(secondPartInfo[3]);
  53. }
  54. else if (secondPartInfo.Length == 5)
  55. {
  56. venue = secondPartInfo[0] + " " + secondPartInfo[1] + " " + secondPartInfo[2];
  57. ticketPrice = int.Parse(secondPartInfo[3]);
  58. ticketsCount = int.Parse(secondPartInfo[4]);
  59. }
  60.  
  61.  
  62. if (!VenuesIncome.ContainsKey(venue))
  63. {
  64. VenuesIncome.Add(venue, new Dictionary<string, long>());
  65. }
  66.  
  67. if (!VenuesIncome[venue].ContainsKey(singer))
  68. {
  69. VenuesIncome[venue].Add(singer, 0);
  70. }
  71.  
  72. VenuesIncome[venue][singer] += ticketPrice * ticketsCount;
  73.  
  74. }
  75.  
  76. //print the venues
  77.  
  78. foreach (var VenueData in VenuesIncome)
  79. {
  80. Console.WriteLine(VenueData.Key);
  81. var orderedSingersList = VenueData.Value.OrderByDescending(x => x.Value).ToList();
  82.  
  83. foreach (var singerData in orderedSingersList)
  84. {
  85. Console.WriteLine($"# {singerData.Key} -> {singerData.Value}");
  86. }
  87. }
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement