Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 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 СръбскоUnleashed
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Dictionary<string, SortedDictionary<string, int[]>> stats = new Dictionary<string, SortedDictionary<string, int[]>>();
  14.             int n = int.Parse(Console.ReadLine());
  15.             for (int i = 0; i < n; i++)
  16.             {
  17.                 string[] input = Console.ReadLine().Split(' ');
  18.                 string type = input[0];
  19.                 string name = input[1];
  20.                 int damage;
  21.                 int health;
  22.                 int armor;
  23.                
  24.  
  25.                     if (input[2] == "null")
  26.                     {
  27.                         damage = 45;
  28.                     }
  29.                     else
  30.                     {
  31.                         damage = int.Parse(input[2]);
  32.                     }
  33.                     if (input[3] == "null")
  34.                     {
  35.                         health = 250;
  36.                     }
  37.                     else
  38.                     {
  39.                         health = int.Parse(input[3]);
  40.                     }
  41.                     if (input[4] == "null")
  42.                     {
  43.                         armor = 10;
  44.                     }
  45.                     else
  46.                     {
  47.                         armor = int.Parse(input[4]);
  48.                     }  
  49.                
  50.  
  51.                 if (!stats.ContainsKey(type))
  52.                 {
  53.                     stats.Add(input[0], new SortedDictionary<string, int[]>());
  54.                 }
  55.                 if (!stats[type].ContainsKey(name))
  56.                 {
  57.                     stats[type][name] = new int[3];
  58.                 }
  59.                 stats[type][name][0]=damage;
  60.                 stats[type][name][1] = health;
  61.                 stats[type][name][2] = armor;
  62.             }
  63.             double avgHealth = 0;
  64.             foreach (var item in stats)
  65.             {
  66.                 var avgDmg = item.Value.Values.Average(a => a[0]);
  67.                 var avghp = item.Value.Values.Average(a => a[1]);
  68.                 var avgAr = item.Value.Values.Average(a => a[2]);
  69.                 Console.WriteLine($"{item.Key}::({avgDmg:F2}/{avghp:F2}/{avgAr:F2})");
  70.                 foreach (var dragon in item.Value)
  71.                 {
  72.                     Console.WriteLine("-"+dragon.Key + " -> damage: " + dragon.Value[0]+", health: " + dragon.Value[1] + ", armor: " + dragon.Value[2]);
  73.                 }
  74.                
  75.                
  76.             }
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement