//通过改变运算符可以完成不同的操作!!!
//两个二维数组进行"加减乘除"
        static void Mains(string[] args)
        {
            int[,] A = new int[,] { { 1, 2, 3 }, { 4, 5, 6 }, { 7, 8, 9 } };
            int[,] B = new int[,] { { 12, 11, 2 }, { 6, 34, 4 }, { 7, 10, 45 } };
            int[,] C = new int[3, 3];

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    C[i, j] = A[i, j] * B[i, j];
                }
            }  

            Console.WriteLine("A二维数组:");
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write(A[i, j] + "\t");
                }
            }
            Console.WriteLine();
            Console.WriteLine("B二维数组:");
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write(B[i, j] + "\t");
                }
            }
            Console.WriteLine();
            Console.WriteLine("相加得出C:");
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write(C[i, j] + "\t");
                }
            }
			Console.Read();
        }
posted on 2019-11-04 09:42  .net之路  阅读(212)  评论(0编辑  收藏  举报