public int[,] ReadArray(int width, int height)
int[,] array = new int[width, height];
for (int i = 0; i < width; i++)
for (int j = 0; j < height; j++)
Console.Write("[{0}, {1}] = ", i, j);
array[i, j] = int.Parse(Console.ReadLine());
Console.WriteLine("You can insert only number!!!\n Please insert [{0}, {1}] = ", i, j);
public void SetWidthHeight(ref int width, ref int height)
Console.Write("Width = ");
width = int.Parse(Console.ReadLine());
Console.WriteLine("You can insert only number!!!\n Width = ");
Console.Write("Height = ");
height = int.Parse(Console.ReadLine());
Console.WriteLine("You can insert only number!!!\n Height = ");
public int FindIndexMax(int[,] array)
int IndexMax = 0, max = array[0,0];
for (int i = 0; i < array.GetLength(0); i++)
for (int j = 0; j < array.GetLength(1); j++)
Console.WriteLine("First amx vlue is in {0} row.", IndexMax - 1);
public int[,] SwapRows(int[,] array, int mindex)
for (int i = 0; i < array.GetLength(1); i++)
array[0, i] = array[mindex, i];
public void ShowArray(int[,] array)
for (int i = 0; i < array.GetLength(0); i++)
for (int j = 0; j < array.GetLength(1); j++)
Console.Write("{0}\t",array[i,j]);
public static void Main(string[] args)
Program pr = new Program();
int width = 0, height = 0, maxind = 0;
pr.SetWidthHeight(ref width, ref height);
int[,] array = pr.ReadArray(width, height);
maxind = pr.FindIndexMax(array);
int[,] newarray = pr.SwapRows(array, maxind);