Esempio n. 1
0
File: Q01_7.cs Progetto: zs9912/ctci
        public void Run()
        {
            int nrows = 10;
            int ncols = 15;

            int[][] matrix1 = AssortedMethods.RandomMatrix(nrows, ncols, 0, 100);
            int[][] matrix2 = CloneMatrix(matrix1);

            AssortedMethods.PrintMatrix(matrix1);

            SetZeros(matrix1);
            SetZeros2(matrix2);

            Console.WriteLine();

            AssortedMethods.PrintMatrix(matrix1);
            Console.WriteLine();
            AssortedMethods.PrintMatrix(matrix2);

            if (MatricesAreEqual(matrix1, matrix2))
            {
                Console.WriteLine("Equal");
            }
            else
            {
                Console.WriteLine("Not Equal");
            }
        }
Esempio n. 2
0
        public void Run()
        {
            const int size = 3;

            int[][] matrix = AssortedMethods.RandomMatrix(size, size, 0, 9);
            AssortedMethods.PrintMatrix(matrix);
            Rotate(matrix, size);
            Console.WriteLine();
            AssortedMethods.PrintMatrix(matrix);
        }
Esempio n. 3
0
        public override void Run()
        {
            const int numberOfRows    = 10;
            const int numberOfColumns = 15;
            var       matrix1         = AssortedMethods.RandomMatrix(numberOfRows, numberOfColumns, 0, 100);

            AssortedMethods.PrintMatrix(matrix1);
            SetZeros(matrix1);
            Console.WriteLine();
            AssortedMethods.PrintMatrix(matrix1);
        }
        public override void Run()
        {
            const int size = 3;

            var matrix = AssortedMethods.RandomMatrix(size, size, 0, 9);

            AssortedMethods.PrintMatrix(matrix);

            Rotate(matrix);
            Console.WriteLine();
            AssortedMethods.PrintMatrix(matrix);
        }
Esempio n. 5
0
        public void Run()
        {
            const int numberOfRows    = 10;
            const int numberOfColumns = 15;
            var       matrix1         = AssortedMethods.RandomMatrix(numberOfRows, numberOfColumns, 0, 100);
            var       matrix2         = CloneMatrix(matrix1);

            AssortedMethods.PrintMatrix(matrix1);

            SetZeros(matrix1);
            SetZeros2(matrix2);

            Console.WriteLine();

            AssortedMethods.PrintMatrix(matrix1);
            Console.WriteLine();
            AssortedMethods.PrintMatrix(matrix2);

            Console.WriteLine(MatricesAreEqual(matrix1, matrix2) ? "Equal" : "Not Equal");
        }