Найти минимальный из максимальных элементов столбцов - C#
Формулировка задачи:
Пользователем вводится двумерный массив целых чисел. Найти
минимальный из максимальных элементов столбцов.
Решение задачи: «Найти минимальный из максимальных элементов столбцов»
textual
Листинг программы
static void Main(string[] args)
{
int[][] mass;
int x, y;
x = Int32.Parse(Console.ReadLine());
y = Int32.Parse(Console.ReadLine());
mass = new int[x][];
for(int i = 0;i<x;i++)
{
int[] temp = Console.ReadLine().Split(' ').Select(Int32.Parse).ToArray();
if(temp.Length!=y)
{
i--;
Console.WriteLine("Error. Try again.");
continue;
}
mass[i] = temp;
}
List<int> max = new List<int>();
for (int i = 0; i < y; i++)
{
int m = mass[0][i];
for (int j = 0; j < x; j++)
{
if (mass[j][i] > m)
m = mass[j][i];
}
max.Add(m);
}
Console.WriteLine(max.Min());
Console.ReadLine();
}