Cooking factory Demo Mid Exam Tech C#
Здравейте,
Може ли някой да ми посочи къде грешa? Получавам 80/100 , гърмят ми 5-ти и 9-ти тест.
Благодаря !
код:
using System;
using System.Collections.Generic;
using System.Linq;
namespace _03_Cooking_Factory
{
class Program
{
static void Main(string[] args)
{
List<int> bestbatch = new List<int> { int.MinValue };
int oldSum = int.MinValue;
double oldAverage = double.MinValue;
int oldCount = 1;
while (true)
{
string input = Console.ReadLine();
if (input == "Bake It!") break;
List<int> currentbatch = input.Split('#').Select(int.Parse).ToList();
int sum = currentbatch.Sum();
double average = (double) sum / currentbatch.Count;
int count = currentbatch.Count;
if (sum > oldSum)
{
bestbatch = currentbatch;
oldSum = sum; oldAverage = average; oldCount = count;
}
else if (sum == oldCount)
{
if (average > oldAverage)
{
bestbatch = currentbatch;
oldSum = sum; oldAverage = average; oldCount = count;
}
else if (average == oldAverage)
{
if (count < oldCount)
{
bestbatch = currentbatch;
oldSum = sum; oldAverage = average; oldCount = count;
}
}
}
}
Console.WriteLine("Best Batch quality: {0}", oldSum)
Console.WriteLine(string.Join(" ", bestbatch));
}
}
}