Помогите исправить код ввода, вывода матрицы - C#
Формулировка задачи:
Подскажите, пожалуйста, что не правильно в коде.По возможности - исправьте.
namespace ConsoleApplication12
{
class Program
{
static Int32[,] InputMatrix(int n, int m)
{
int[,] result = new Int32[n, m];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < m; j++)
{
Console.WriteLine("Введите элемент {0} строки {1} столбца массива: ", i + 1, j + 1);
result[i, j] = Convert.ToInt32(Console.ReadLine());
}
}
return result;
}
static void OutputMatrix(Int32[,] Matrix)
{
for (int i = 0; i < Matrix.Length; i++)
{
for (int j = 0; j < Matrix.Length; j++)
{
Console.Write("{0}\t", Matrix[i, j]);
}
Console.WriteLine();
}
}
static void Main(string[] args)
{
int n = 0;
int m = 0;
while ((n <= 0) && (m <= 0))
{
Console.WriteLine("Введите количество строк: ");
n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Введите количество столбцов: ");
m = Convert.ToInt32(Console.ReadLine());
}
Int32[,] Matrix = InputMatrix(n,m);
Console.WriteLine("Введенная матрица: ");
OutputMatrix(Matrix);
Console.ReadKey();
}
}
}Решение задачи: «Помогите исправить код ввода, вывода матрицы»
textual
Листинг программы
static void OutputMatrix(Int32[,] Matrix)
{
for (int i = 0; i < Matrix.Length; i++) //Matrix.GetLength(0)
{
for (int j = 0; j < Matrix.Length; j++) //Matrix.GetLength(1)
{
Console.Write("{0}\t", Matrix[i, j]);
}
Console.WriteLine();
}
}