← 返回 capitalone 的题目列表Matrix Manipulation
类型:online_judge
Given a matrix and a set of operations, perform one of the following operations:
Swap two rows
Swap two columns
Reverse a specified row
Reverse a specified column
Rotate the matrix 90 degrees clockwise
Please implement these operations and run the respective operations for given inputs. Assume the input matrix is not strictly n x n and could be m x n.
Input
The first line will be an integer T, which is the number of operations.
Followed by m lines and n columns representing the matrix.
The next T lines consist of an operation described by space-separated letters and numbers.
Output
Output the modified matrix after each operation.
Example
Input
3
1 2 3
4 5 6
swap_rows 0 1
reverse_row 0
rotate_90
Output
4 5 6
1 2 3
6 5 4
2 5 1
3 6 1