, , . # , , . "and quit if m = 1", , . , Peak() , .
static void Peak(int[,] map, int left, int right)
{
int column = (right + left) / 2;
int arow = 0;
for (int row = 0; row < map.GetLength(0); row++)
if (map[row, column] > map[arow, column])
arow = row;
int a = map[arow, column];
int b = 0;
if (column - 1 >= left) b = map[arow, column - 1];
int c = 0;
if (column + 1 <= right) c = map[arow, column + 1];
if (b > a) Peak(map, left, column - 1);
else if (c > a) Peak(map, column + 1, right);
else Console.WriteLine("Peak: " + arow + " " + column + " " + a);
}
static void Main(string[] args)
{
int[,] map = { {12, 8, 5},
{11, 3, 6 },
{10, 9, 2 },
{ 8, 4, 1 } };
Peak(map, 0, 2);
Console.ReadLine();
}