Не можу знайти помилки, хелп пліз!
Call a method GetNumbersFromConsole that reads a count value of double, and then reads count values from the console into a double array. Find the maximum of the values in the array and print “Max is: {number}” to the console. For example:
>3
>1.12
>-2.333
>399.76
Max is: 399.76
Here is my code:
namespace Arrays
{
class MaxInArray
{
public static void Main(string[] args)
{
double[] numbers = GetNumbersFromConsole();
double max = numbers[0];
for (int i = 0; i < numbers.Length; ++i)
if (numbers[i] > max)
{
numbers[i] = max;
Console.WriteLine($"Max is: {max}");
}
}
static double[] GetNumbersFromConsole()
{
int count = int.Parse(Console.ReadLine());
double[] result = new double[count];
for (int i = 0; i < count; ++i)
{
result[i] = double.Parse(Console.ReadLine());
}
return result;
}
}
}