Advertisement
EmoRz

DragonArmy

Jun 9th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace DragonArmy
  6. {
  7.     class Program
  8.     {
  9.         public static object Dicitionary { get; private set; }
  10.  
  11.         static void Main(string[] args)
  12.         {
  13.             //Red Bazgargal 100 2500 25
  14.             //for
  15.             //{type} {name} {damage} {health} {armor}.
  16.  
  17.             var iteration = int.Parse(Console.ReadLine());
  18.  
  19.             Dictionary<string, Dictionary<string, List<int>>> data = new Dictionary<string, Dictionary<string, List<int>>>();
  20.  
  21.  
  22.             for (int i = 0; i < iteration; i++)
  23.             {
  24.                 string[] input = Console.ReadLine().Split(' ').ToArray();
  25.                 var type = input[0];
  26.                 var name =input[1];
  27.                 //
  28.                 var damage = 0;
  29.                 var health = 0;
  30.                 var armour = 0;
  31.                 if (input[2] == "null")
  32.                 {
  33.                     damage = 45;
  34.                 }
  35.                 if (input[2] != "null")
  36.                 {
  37.                     damage = int.Parse(input[2]);
  38.                 }
  39.                 if (input[3] == "null")
  40.                 {
  41.                     health = 250;
  42.                 }
  43.                 if (input[3] != "null")
  44.                 {
  45.                     health = int.Parse(input[3]);
  46.                 }
  47.                 if (input[4] == "null")
  48.                 {
  49.                     armour = 10;
  50.                 }
  51.                 if (input[4] != "null")
  52.                 {
  53.                     armour = int.Parse(input[4]);
  54.                 }
  55.                 //
  56.                 if (!data.ContainsKey(type))
  57.                 {
  58.                     data.Add(type, new Dictionary<string, List<int>>());
  59.                 }
  60.                 if (!data[type].ContainsKey(name))
  61.                 {
  62.                     data[type].Add(name, new List<int>());
  63.                 }
  64.                 List<int> current = new List<int>();
  65.                 current.Add(damage);
  66.                 current.Add(health);
  67.                 current.Add(armour);
  68.                 data[type][name] = current;
  69.  
  70.             }
  71.             foreach (var dragon in data)
  72.             {
  73.                 var midHealth = 0;
  74.                 var midDamage = 0;
  75.                 var midArmour = 0;
  76.                 var count = dragon.Value.Count();
  77.                 foreach (var pro in dragon.Value)
  78.                 {
  79.                     midHealth += pro.Value[1];
  80.                     midArmour += pro.Value[2];
  81.                     midDamage += pro.Value[0];
  82.  
  83.                 }
  84.                 Console.WriteLine(dragon.Key+$"::({midDamage*1.0/count:f2}/{midHealth*1.0/count:f2}/{midArmour * 1.0 / count:f2})");
  85.              
  86.                 foreach (var properties in dragon.Value.OrderBy(x => x.Key))
  87.                 {
  88.                     Console.Write("-"+properties.Key+ " -> ");
  89.                     Console.Write($"damage: {properties.Value[0]}, health: {properties.Value[1]}, armor: {properties.Value[2]}");
  90.                     midDamage += properties.Value[0];
  91.                     midHealth += properties.Value[1];
  92.                     midArmour += properties.Value[2];
  93.                     Console.WriteLine();
  94.                 }
  95.             }
  96.         }
  97.     }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement