Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2017
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace DragonArmy
  7. {
  8.     class DragonArmy
  9.     {
  10.         static void Main()
  11.         {
  12.             int numberOfLines = int.Parse(Console.ReadLine());
  13.             Dictionary<string, List<Dictionary<string, List<Dictionary<string, int>>>>> dragons = new Dictionary<string, List<Dictionary<string, List<Dictionary<string, int>>>>>();
  14.  
  15.             for (int i = 0; i < numberOfLines; i++)
  16.             {
  17.                 string[] input = Console.ReadLine().Split(' ');
  18.                 SetDefaultValues(input);
  19.  
  20.                 List<Dictionary<string, int>> dragonStats = new List<Dictionary<string, int>>();
  21.                 Dictionary<string, List<Dictionary<string, int>>> dragon = new Dictionary<string, List<Dictionary<string, int>>>();
  22.  
  23.                 string dragonColor = input[0];
  24.                 string dragonName = input[1];
  25.                 int dragonDamage = int.Parse(input[2]);
  26.                 int dragonHealth = int.Parse(input[3]);
  27.                 int dragonArmor = int.Parse(input[4]);
  28.  
  29.                 dragonStats.Add(new Dictionary<string, int> { { "damage", dragonDamage } });
  30.                 dragonStats.Add(new Dictionary<string, int> { { "health", dragonHealth } });
  31.                 dragonStats.Add(new Dictionary<string, int> { { "armor", dragonArmor } });
  32.  
  33.                 dragon.Add(dragonName, dragonStats);
  34.            
  35.  
  36.                 if (!dragons.ContainsKey(dragonColor))
  37.                 {
  38.                    dragons.Add(dragonColor, new List<Dictionary<string, List<Dictionary<string, int>>>> { dragon});
  39.                 }
  40.                 else
  41.                 {
  42.                     if(!dragons.ContainsValue(new List<Dictionary<string, List<Dictionary<string, int>>>> { dragon }))
  43.                     {
  44.                         dragons[dragonColor].Add(dragon);
  45.                     }
  46.                 }
  47.             }
  48.  
  49.  
  50.             //Стигам до тук
  51.             foreach (var dragon in dragons)
  52.             {
  53.                 string name = dragon.Key;
  54.                 Console.WriteLine("{0}::({1:0.00}/{2:0.00}/{3:0.00})",name,dragon.Value.Average(x=>x.Values.));
  55.             }
  56.         }
  57.  
  58.  
  59.  
  60.         private static string[] SetDefaultValues(string[] input)
  61.         {
  62.             for (int i = 0; i < input.Length; i++)
  63.             {
  64.                 if(input[i] == "null")
  65.                 {
  66.                     if(i == 2)
  67.                     {
  68.                         input[i] = "250";
  69.                     }
  70.                     else if(i == 3)
  71.                     {
  72.                         input[i] = "45";
  73.                     }
  74.                     else if(i == 4)
  75.                     {
  76.                         input[i] = "10";
  77.                     }
  78.                 }
  79.             }
  80.             return input;
  81.         }
  82.     }
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement