10992 - Matrix class   

Description

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

Provide public member functions that perform or derive:

  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.

 

Hint:

Transpose of a Matrix:

A matrix which is formed by turning all the rows of a given matrix into column and vice-versa.

 


Example:

Note:

1.  This problem involves three files.

  • function.h: Class definition of Matrix.
  • function.cpp: Member-function definitions of Matrix.
  • main.cpp: A driver program to test your class implementation.

You will be provided with function.h and main.cpp, and asked to implement function.cpp.

 

 

function.h

main.cpp

2. For OJ submission:

       Step 1. Include function.h into function.cpp and then implement your function.cpp. (You don’t need to modify function.h and main.cpp)

       Step 2. Submit the code of function.cpp into submission block.

       Step 3. Check the results and debug your program if necessary.

 

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, and the following N lines specify those of the second matrix b. All of the integers in the same line are separated by a space.

Output

Your program should print the corresponding results followed by a new line character.

Sample Input  Download

Sample Output  Download

Partial Judge Code

10992.cpp

Partial Judge Header

10992.h

Tags

10402HW5



Discuss