| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11407 | Matrix Computation |
|
| 11414 | Matrix Computation |
|
Description
Create a class Matrix to represent a N * N matrix.
Provide public member functions that perform the following tasks:
- Matrix addition.
- Matrix subtraction.
- Matrix Multiplication.
- Adding cell value by 1 (module 10). That is, if after adding 1, a cell value becomes 10 we change it to 0.
- Matrix Transpose.
Input
The first line has an integer N (1<=N<=50), which means the size of the matrix. The total number of elements in the matrix is thus N * N.
For the next 2N lines:
- The first N lines specify the elements of the first matrix a.
- The following N lines specify the elements of the second matrix b.
All elements in matrix are in the range of 0-9.
All elements in the same line are separated by a space.
Output
Output the answer of each task.
In the matrix, all of the integers in the same line are separated by a space, and a newline character at the end of the line.
Ex:
1 2 3"\n"
4 5 6"\n"
7 8 9"\n"
Note : In main function, there is already a newline character between each matrix.
Sample Input Download
Sample Output Download
Partial Judge Code
11407.cppPartial Judge Header
11407.hTags
Discuss
Description
Create a class Matrix to represent an N x N matrix.

Provide public member functions that perform or derive:
- Interchanging two rows.
- Rotating Matrix by 90° clockwise.
- Rotating Matrix by 90° counter clockwise.
- Checking if Matrix is symmetric or not. If yes, print “yes”, otherwise, print “no”.
Hint:
- Symmetric
A matrix A = (aij) is symmetric if its entries are symmetric with respect to the main diagonal, that is, aij = aji, for all indices i and j.
The following 3 x 3 matrix is symmetric:
1 7 3
7 4 -5
3 -5 6
Input
The first line contains an integer N (2<=N<=50), which means the size of the matrix. The total number of elements in the matrix is thus N x N.
For the next N lines, each line contains N integers, specifying the elements of the matrix.
The last line has two integers, which mean two row indices for performing row exchange.
All of the integers in the same line are separated by a space.
Output
Print out the corresponding results with a new line character at the end of each result.