C#中怎样将2维数组中的数据按照矩阵输出来?

来源:百度知道 编辑:UC知道 时间:2024/06/08 10:09:22

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
{
class Second
{
static void Main(string[] args)
{
double[,] a = double[,] a = { { 0, 1,1 }, { 1, 2,5 }, { 1, 3,8 }, { 5,2,9} };
//自动获得第1维的长度,以便你自由修改上面的值
for (int i = 0; i < a.GetLength(0); i++)
{
//自动获得第2维的长度,以便你自由修改上面的值
for (int j = 0; j < a.GetLength(1); j++)
{
Console.Write(a[i,j]+"\t");
}
Console.WriteLine();
}
Console.ReadLine();
}
}
}