using System;
public class Test
{
public static void Main()
{
int[,] matrizA = new int[2, 2];
int[,] matrizB = new int[2, 2];
matrizA[0, 0] = 1;
matrizA[0, 1] = 2;
matrizA[1, 0] = 3;
matrizA[1, 1] = 4;
matrizB[0, 0] = 1;
matrizB[0, 1] = 2;
matrizB[1, 0] = 3;
matrizB[1, 1] = 4;
int[,] matrizC = Sum(matrizA, matrizB);
View(matrizC);
}
public static int[,] Sum(int[,] a, int[,] b)
{
int[,] result = new int[a.Rank, a.Rank];
for (int i = 0; i < a.Rank; i++)
for (int j = 0; j < a.Rank; j++)
result[i, j] = a[i, j] + b[i, j];
return result;
}
public static void View(int[,] a)
{
for (int i = 0; i < a.Rank; i++)
{
for (int j = 0; j < a.Rank; j++)
System.Console.Write("{0} ", a[i, j]);
System.Console.WriteLine();
}
}
}
dXNpbmcgU3lzdGVtOwoKcHVibGljIGNsYXNzIFRlc3QKewoJcHVibGljIHN0YXRpYyB2b2lkIE1haW4oKQoJewoJCWludFssXSBtYXRyaXpBID0gbmV3IGludFsyLCAyXTsKCQlpbnRbLF0gbWF0cml6QiA9IG5ldyBpbnRbMiwgMl07CgkKCQltYXRyaXpBWzAsIDBdID0gMTsKCQltYXRyaXpBWzAsIDFdID0gMjsKCQltYXRyaXpBWzEsIDBdID0gMzsKCQltYXRyaXpBWzEsIDFdID0gNDsKCQoJCW1hdHJpekJbMCwgMF0gPSAxOwoJCW1hdHJpekJbMCwgMV0gPSAyOwoJCW1hdHJpekJbMSwgMF0gPSAzOwoJCW1hdHJpekJbMSwgMV0gPSA0OwoJCgkJaW50WyxdIG1hdHJpekMgPSBTdW0obWF0cml6QSwgbWF0cml6Qik7CgkJVmlldyhtYXRyaXpDKTsKCX0KCXB1YmxpYyBzdGF0aWMgaW50WyxdIFN1bShpbnRbLF0gYSwgaW50WyxdIGIpCiAgICB7CiAgICAgICAgaW50WyxdIHJlc3VsdCA9IG5ldyBpbnRbYS5SYW5rLCBhLlJhbmtdOwogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgYS5SYW5rOyBpKyspCiAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgYS5SYW5rOyBqKyspCiAgICAgICAgICAgICAgICByZXN1bHRbaSwgal0gPSBhW2ksIGpdICsgYltpLCBqXTsKICAgICAgICByZXR1cm4gcmVzdWx0OwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBWaWV3KGludFssXSBhKQogICAgewogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgYS5SYW5rOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IGEuUmFuazsgaisrKQogICAgICAgICAgICAgICAgU3lzdGVtLkNvbnNvbGUuV3JpdGUoInswfSAiLCBhW2ksIGpdKTsKICAgICAgICAgICAgU3lzdGVtLkNvbnNvbGUuV3JpdGVMaW5lKCk7CiAgICAgICAgfQogICAgICAgICAgICAKICAgIH0KfQ==