Ejemplo n.º 1
0
 public void Search2DMetrix_a_Test()
 {
     int[][] targetMatrix = new int[][] { new int[] { 1, 3, 5, 7 },
                                          new int[] { 10, 11, 16, 20 },
                                          new int[] { 23, 30, 34, 50 } };
     Assert.IsTrue(Search2DMatrix.Search2DMatrix_a(targetMatrix, 3));
 }
Ejemplo n.º 2
0
 public void Search2DMetrix_b_Test()
 {
     //int[][] sourceMetrix = new int[][] { }
     int[][] sourceMatrix = new int[][] {
         new int[] { 1, 2 },
         new int[] { 3, 4 }
     };
     Assert.IsTrue(Search2DMatrix.Search2DMatrix_b(sourceMatrix, 3));
 }
Ejemplo n.º 3
0
        public static void TMain(string[] args)
        {
            Search2DMatrix m = new Search2DMatrix();

            int[,] grid2 = new[, ]
            {
                { 1, 2, 3, 4, 5 },
                { 6, 7, 8, 9, 10 },
                { 11, 12, 13, 14, 15 },
                { 16, 17, 18, 19, 20 },
                { 21, 22, 23, 24, 25 }
            };

            W(m.SearchMatrix(new[, ]
            {
                {
                    93, 157, 226, 308, 365, 384, 479, 539, 557, 652
                },
                {
                    118, 234, 287, 368, 395, 432, 480, 607, 634, 723
                },
                {
                    132, 263, 381, 453, 525, 533, 577, 650, 707, 800
                },
                {
                    171, 307, 473, 504, 526, 596, 643, 719, 776, 842
                },
                {
                    233, 319, 514, 571, 668, 710, 733, 777, 875, 886
                },
                {
                    318, 362, 555, 605, 717, 782, 809, 884, 889, 940
                },
                {
                    349, 415, 622, 708, 787, 795, 824, 921, 957, 1014
                },
                {
                    414, 420, 656, 789, 813, 898, 954, 1052, 1095, 1175
                },
                {
                    430, 477, 705, 863, 961, 991, 1003, 1121, 1190, 1236
                },
                {
                    524, 611, 793, 868, 1027, 1111, 1112, 1123, 1252, 1253
                }
            }, 430));
            W(m.SearchMatrix(grid2, 11));
            W(m.SearchMatrix(grid2, 5));
            W(m.SearchMatrix(grid2, 15));
            int[,] grid =
            {
                {
                    1, 4, 7, 11, 15
                },
                {
                    2, 5, 8, 12, 19
                },
                {
                    3, 6, 9, 16, 22
                },
                {
                    10, 13, 14, 17, 24
                },
                {
                    18, 21, 23, 26, 30
                }
            };
            W(m.SearchMatrix(new[, ]
            {
                {
                    1, 4, 7, 11, 15
                }
            }, 4));
            W(m.SearchMatrix(new[, ]
            {
                {
                    1, 4, 7, 11, 15
                }
            }, 15));
            W(m.SearchMatrix(new[, ]
            {
                {
                    1, 4, 7, 11, 15
                }
            }, 1));
            W(m.SearchMatrix(grid, 20));
        }
Ejemplo n.º 4
0
        void InternalTest(int[][] matrix, int target, bool expected)
        {
            bool value = Search2DMatrix.SearchMatrix(matrix, target);

            Assert.Equal <bool>(expected, value);
        }
Ejemplo n.º 5
0
 public void Search2DMetrix_b_TestNull()
 {
     int[][] sourceMetrix = new int[][] { new int[] { } };
     Assert.IsFalse(Search2DMatrix.Search2DMatrix_b(sourceMetrix, 2));
 }
Ejemplo n.º 6
0
 public void Search2DMetrix_a_TestNull()
 {
     int[][] targetMatrix = new int[][] { new int[] { } };
     Assert.IsFalse(Search2DMatrix.Search2DMatrix_a(targetMatrix, 2));
 }