проблем със задача 3. Legendary Farming-Exercise: Associative Arrays C# Fundamentals - май 2020
Здравейте ,резултатите на задачта излизат във VS, но в системата не излизат - 10т.
using System;
using System.Collections.Generic;
using System.Linq;
namespace Count_Real_Numbers
{
class Program
{
static void Main(string[] args)
{
string[] items = Console.ReadLine().ToLower().Split().ToArray();
Dictionary<string, int> totalItems1 = new Dictionary<string, int>();
Dictionary<string, int> totalItems2 = new Dictionary<string, int>();
totalItems2.Add("shards", 0);
totalItems2.Add("fragments", 0);
totalItems2.Add("motes", 0);
string symbol = "";
for (int i = 0; i < items.Length; i += 2)
{
string element = items[i + 1];
int quantity = int.Parse(items[i]);
byte count = 1;
switch (element)
{
case "shards":
symbol = "Shadowmourne";
break;
case "fragments":
symbol = "Valanyr";
break;
case "motes":
symbol = "Dragonwrath";
break;
default:
count = 0;
break;
}
if (count == 0)
{
if (totalItems1.ContainsKey(element))
{
totalItems1[element] += quantity;
}
else
{
totalItems1.Add(element, quantity);
}
}
else
{
totalItems2[element] += quantity;
if (totalItems2[element] >= 250)
{
totalItems2[element] -= 250;
Console.WriteLine(symbol + " obtained!");
break;
}
}
///3 Motes 5 stones 5 Shards 6 leathers 255 fragments 7 Shards
///123 silver 6 shards 8 shards 5 motes 9 fangs 75 motes 103 MOTES 8 Shards 86 Motes 7 stones 19 silver
}
foreach (var item in totalItems2.OrderByDescending(x => x.Value).ThenBy(x => x.Key))
{
Console.WriteLine(item.Key + ": " + item.Value);
}
foreach(var item in totalItems1.OrderBy(x => x.Key))
{
Console.WriteLine(item.Key + ": " + item.Value);
}
}
}
}