11407 - Matrix Computation   

Description

Create a class Matrix to represent a N * N matrix.

Provide public member functions that perform the following tasks:

  1. Matrix addition.
  2. Matrix subtraction.
  3. Matrix Multiplication.
  4. Adding cell value by 1 (module 10). That is, if after adding 1, a cell value becomes 10 we change it to 0.
  5. 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.cpp

Partial Judge Header

11407.h

Tags




Discuss