昨天看了清华大学严蔚敏老师的数据结构的视频,讲到了数组,严蔚敏老师认真分析了一个关于两个二维数组的算法,那个算法是用c语言写的,反复看了两遍才把那个算法看懂了。今天上班上午没事做,干脆把昨天的算法改成C#语言版的。(嘿嘿,俺只对C#语言比较了解)
这是俺写的代码:
class IArray
{
int[,] aArray = new int[, ] { { 0, 0, 2 }, { 1, 0, 3 }, { 0, 4, 0 }, { 2, 1, 0 } };
int[,] bArray = new int[, ] { { 1, 0 }, { 0, 4 }, { 2, 1 } };
public void GetValue()
{
Console.WriteLine("第一个数组如下:");
for (int i = 0; i < aArray.GetLength(0); i++)
{
for (int j = 0; j < aArray.GetLength(1); j++)
{
Console.Write("{0} ", aArray[i, j]);
}
Console.WriteLine();
}