Walczę już od paru godzin z tym problemem. w kompilatorze wszystko poprawnie działa. Już nie mam pomysłów.
var t = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < t; i++)
{
var y = Convert.ToInt32(Console.ReadLine());
float[] table = new float[y];
float sum = 0;
for (int j = 0; j < y; j++)
{
table[j] = Convert.ToInt32(Console.ReadLine());
sum += table[j];
}
sum = sum / y;
var buf = Math.Abs(table[0] - sum);
var count = 0;
for (int j = 1; j < y; j++)
{
if (buf > Math.Abs(table[j] - sum))
{
buf = Math.Abs(table[j] - sum);
count=j;
}
}
Console.WriteLine(table[count]);
}