Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 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 BeerPong
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var Data = new Dictionary<string, Dictionary<string, int>>();
  14. string input = Console.ReadLine();
  15. while (input != "stop the game")
  16. {
  17.  
  18. string[] inputTokens = input.Split('|');
  19. string name = inputTokens[0];
  20. string Team = inputTokens[1];
  21. int points = int.Parse(inputTokens[2]);
  22. if (!Data.ContainsKey(Team))
  23. {
  24. Data[Team]= new Dictionary<string, int>();
  25. }
  26. if (Data[Team].Values.Count==3)
  27. {
  28. input = Console.ReadLine();
  29. continue;
  30. }
  31. Data[Team][name] = points;
  32. input = Console.ReadLine();
  33. }
  34. int count = 0;
  35. foreach (var comp in Data.Where(x=> x.Value.Count>= 3).OrderByDescending(x => x.Value.Values.Sum()))
  36. {
  37. count++;
  38. Console.WriteLine("{0}. {1}; Players:", count, comp.Key);
  39. foreach (var player in comp.Value.OrderByDescending(x=>x.Value))
  40. {
  41. Console.WriteLine($"###{player.Key}: {player.Value}");
  42. }
  43.  
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement