二維陣列的計算

cvMat發表於2016-12-19
namespace 二維陣列的計算
{
    class Program
    {
        static void Main(string[] args)
        {
            short[,] b = new short[5, 5] { { 1, 2, 3, 4, 5 }, { 1, 1, 1, 1, 1 },
            { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 } };
            short[,] c = new short[5, 5] { { 1, 2, 3, 4, 5 }, { 1, 1, 0, 0, 1 },
            { 1, 0, 0, 1, 1 }, { 1, 1, 1, 1, 1 }, { 1, 1, 1, 1, 1 } };
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    short a;
                    a = (short)(b[i, j] - c[i, j]);
                    Console.Write(a);   
                 }
                Console.Write("\n");
            }
            Console.ReadLine();

        }
    }
}

相關文章