2DArray method:It will allocate a block of memory which represents a two-dimension array based on the input values supplied by the user. Ask the user to enter the number of rows and column for 2D array that the user want to manipulate. The number of rows and columns that the user enters may or may not define a square matrix (when the number of rows equals the number of columns). The array will have exactly rows time columns (m * n) elements. It will not contain any extra or empty cells. Initialize the “matrix” by rows with random number between 1 to 100. Pass two arguments by out reference so that you can assign the number of row and columns of data to the first and second arguments. This is return 2D array method after allocating new memory for 2D array and initialize it with random value. Generate random number code in C# as following: Random randnum = new Random( ); int number = randnum.Next (1, 101); SwapRow method: it will rotate the data in the matrix in an up/down method such that the first row is exchanged with last row (swap row 0 and row m-1, swap row 1 and row m-2, etc.). SwapColumn method: it will rotate the data in the matrix in a left/right method such that the first column is exchanged with the last column (swap column 0 and column n-1, swap column1 and column n-2, etc.) RotateLeftDiagonal method: it will rotate the data in the matrix by the left diagonal. This operation is usually referred to as a matrix transpose. This is done by exchanging element [i, j] with element [j, i]. The values on the left diagonal do not move for a square matrix. Do not forget to swap the values for the number of rows and columns. Pass these two arguments by reference so that you can change their values. RotateRightDiagonal method: it will rotate the data in the matrix by the right diagonal. This operation will require that you exchange element [0, 0] with element [m-1, n-1]. The values on the right diagonal do not move for a square matrix. Do not forget to swap the values of the number of rows and columns. Pass these two arguments by reference so that you can change their values. DisplayArray method: it will print the array in a two-dimension format with rows and columns as you would normally print a compile time defined two-dimension array. Be sure that the columns are aligned correctly for display purposes. Use type integer (int) for the array. In the main, program call methods in following order: 2DArray, SwapRow, SwapColumn, RotateLeftDiagonal, RotateRightDiagonal. After each method has been called you must print the matrix, which is calling DisplayArray method, and pause the program so that the result of the operation can be viewed. After the results of the operation of 4 methods has been printed, then continue running the program until the user want to quit. Clearly label each matrix with the operation that was performed on the matrix.
2DArray method:It will allocate a block of memory which represents a two-dimension array
based on the input values supplied by the user. Ask the user to enter the number of rows and
column for 2D array that the user want to manipulate. The number of rows and columns that the
user enters may or may not define a square matrix (when the number of rows equals the number
of columns). The array will have exactly rows time columns (m * n) elements. It will not
contain any extra or empty cells. Initialize the “matrix” by rows with random number between 1
to 100. Pass two arguments by out reference so that you can assign the number of row and
columns of data to the first and second arguments. This is return 2D array method after
allocating new memory for 2D array and initialize it with random value. Generate random
number code in C# as following: Random randnum = new Random( );
int number = randnum.Next (1, 101);
SwapRow method: it will rotate the data in the matrix in an up/down method such that the first
row is exchanged with last row (swap row 0 and row m-1, swap row 1 and row m-2, etc.).
SwapColumn method: it will rotate the data in the matrix in a left/right method such that the
first column is exchanged with the last column (swap column 0 and column n-1, swap column1
and column n-2, etc.)
RotateLeftDiagonal method: it will rotate the data in the matrix by the left diagonal. This
operation is usually referred to as a matrix transpose. This is done by exchanging element [i, j]
with element [j, i]. The values on the left diagonal do not move for a square matrix. Do not
forget to swap the values for the number of rows and columns. Pass these two arguments by
reference so that you can change their values.
RotateRightDiagonal method: it will rotate the data in the matrix by the right diagonal. This
operation will require that you exchange element [0, 0] with element [m-1, n-1]. The values on
the right diagonal do not move for a square matrix. Do not forget to swap the values of the
number of rows and columns. Pass these two arguments by reference so that you can change
their values.
DisplayArray method: it will print the array in a two-dimension format with rows and columns
as you would normally print a compile time defined two-dimension array. Be sure that the
columns are aligned correctly for display purposes.
Use type integer (int) for the array. In the main, program call methods in following order:
2DArray, SwapRow, SwapColumn, RotateLeftDiagonal, RotateRightDiagonal. After each
method has been called you must print the matrix, which is calling DisplayArray method, and
pause the program so that the result of the operation can be viewed. After the results of the
operation of 4 methods has been printed, then continue running the program until the user want
to quit. Clearly label each matrix with the operation that was performed on the matrix.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps