Beispiel #1
0
        public void ComputeAreaTest()
        {
            var res = MatrixProblems.ComputeArea(-3, 0, 3, 4, 0, -1, 9, 2);

            Assert.AreEqual(45, res);
            res = MatrixProblems.ComputeArea(-2, -2, 2, 2, 3, 3, 4, 4);
            Assert.AreEqual(17, res);
            res = MatrixProblems.ComputeArea(-1500000001, 0, -1500000000, 1, 1500000000, 0, 1500000001, 1);
            Assert.AreEqual(2, res);
        }
        public void Run()
        {
            System.Console.WriteLine("Printing Matrix.");
            MatrixProblems.PrintMatrix(matrix);

            //MatrixProblems.PrintSpiral(matrix, 0, matrix.GetLength(0) - 1, 0, matrix.GetLength(1) - 1);

            //System.Console.WriteLine("\nRotating Clockwise.");
            //MatrixProblems.RotateMatrix(matrix, 0, matrix.GetLength(0) - 1, 0, matrix.GetLength(1) - 1);
            //MatrixProblems.PrintMatrix(matrix);

            MatrixProblems.RotateMatrix90DegAntiClockWise(matrix);
            MatrixProblems.PrintMatrix(matrix);
        }
Beispiel #3
0
        public void rotateImageTest()
        {
            var arr = new int[3][];

            arr[0] = new int[3] {
                1, 2, 3
            };
            arr[1] = new int[3] {
                4, 5, 6
            };
            arr[2] = new int[3] {
                7, 8, 9
            };

            var res = MatrixProblems.rotateImage(arr);
        }
Beispiel #4
0
        public void PrintMatrixInSpiralTest()
        {
            // arrange
            int[,] M = new int[, ] {
                { 1, 2, 3, 4, 5 },
                { 6, 7, 8, 9, 10 },
                { 11, 12, 13, 14, 15 },
                { 16, 17, 18, 19, 20 }
            };

            // act
            MatrixProblems mp = new MatrixProblems();

            mp.PrintMatrixInSpiral(M);

            // assert
        }