static void Main(string[] args)
{
int a = 0;
int b = 0;
Console.WriteLine("Enter number");
int X = Convert.ToInt32(Console.ReadLine());
int[] numbers = new int[X];
Console.WriteLine("Choose interval:\n" + "1) -40 50;\n" + "2) -100 90;\n" + "3) -300 290;\n");
int N = Convert.ToInt32(Console.ReadLine());
switch (N)
{
case 1:
a = -40; b = 50;
break;
case 2:
a = -100; b = 90;
break;
case 3:
a = -300; b = 290;
break;
default:
Console.Write("Error. You dont choose correct interval ");
break;
}
Random rnd = new Random();
int rndNumb;
for (int i = 0; i < X; i++)
{
rndNumb = rnd.Next(a, b);
numbers[i] = rndNumb;
}
int max = numbers[0];
int min = numbers[0];
for (int i = 1; i < X; i++)
{
if (numbers[i] > max && i % 5 == 0)
{
max = numbers[i];
}
if (numbers[i] < min && i % 5 == 0)
{
min = numbers[i];
}
}
Console.Write("Maximum even element is : {0}\n", max);
Console.Write("Minimum even element is : {0}\n\n", min);
}
Console.WriteLine("Enter number");
int X = Convert.ToInt32(Console.ReadLine());
Random rnd = new Random();
int rndNumb;
for (int i = 0; i < X; i++)
{
rndNumb = rnd.Next(a, b);
numbers[i] = rndNumb;
}
просто мусор. Тут будут повторы. Решение не будет верным.