Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program
- {
- static void Main(string[] args)
- {
- // Решение с Array (ако трябваше да ползваш много място просто правиш масив с много значения - примерно new int[1000] )
- Dictionary<string, SortedDictionary<string, int[]>> dict = new Dictionary<string, SortedDictionary<string, int[]>>();
- int num = int.Parse(Console.ReadLine());
- for (int i = 0; i < num; i++)
- {
- string[] input = Console.ReadLine().Split(' ');
- string team = input[0];
- string name = input[1];
- int damage = (input[2] == "null") ? 45 : int.Parse(input[2]);
- int health = (input[3] == "null") ? 250 : int.Parse(input[3]);
- int armor = (input[4] == "null") ? 10 : int.Parse(input[4]);
- if (!dict.ContainsKey(team))
- { dict.Add(team, new SortedDictionary<string, int[]>()); }
- if (!dict[team].ContainsKey(name))
- { dict[team].Add(name, new int[3]); }
- // няма нужда от предварително почистване като с List
- dict[team][name][0] = damage;
- dict[team][name][1] = health;
- dict[team][name][2] = armor;
- }
- foreach (KeyValuePair<string, SortedDictionary<string, int[]>> team in dict)
- {
- double damageSum = 0, healthSum = 0, armorSum = 0;
- Console.Write("{0}::", team.Key);
- foreach (KeyValuePair<string, int[]> teamData in team.Value)
- {
- damageSum += teamData.Value.ElementAt(0);
- healthSum += teamData.Value.ElementAt(1); ;
- armorSum += teamData.Value.ElementAt(2); ;
- }
- Console.WriteLine("({0:F2}/{1:F2}/{2:F2})", damageSum / team.Value.Count(), healthSum / team.Value.Count(), armorSum / team.Value.Count());
- foreach (KeyValuePair<string, int[]> teamData in team.Value)
- {
- Console.WriteLine("-{0} -> damage: {1}, health: {2}, armor: {3}", teamData.Key, teamData.Value.ElementAt(0), teamData.Value.ElementAt(1), teamData.Value.ElementAt(2));
- }
- }
- } // end lines
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement