using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace practise { class Program { static void Main(string[] args) { //矩阵A int[,] A = { { 1, 2, 3 }, { 3, 4, 5 }, { 1, 3, 5 } }; //矩阵B int[,] B = { { 1, 2, 3 }, { 3, 4, 5 }, { 2, 4, 6 } }; //矩阵C int[,] C = new int[3, 3]; //循环给C赋值 for (int i = 0; i < A.GetLength(0); i++) { for (int j = 0; j < B.GetLength(1); j++) { C[i, j] = A[i, j] + B[i, j]; } } Print(A); Print(B); Print(C); Console.Read(); } static void Print(int[,] arry) { Console.WriteLine("---------"); for (int i = 0; i < arry.GetLength(0); i++) { for (int j = 0; j < arry.GetLength(1); j++) { Console.Write(arry[i, j]); Console.Write(" "); } Console.WriteLine(); } Console.WriteLine("---------"); } } }