Professional Documents
Culture Documents
Lab1 - Specification
Lab1 - Specification
Lab1 - Specification
Input format
The input begins with an integer n on a line, which means that there are n test cases.
And the first character of each following row is the command.
+ : add two matrices.
* : multiply two matrices.
p : print the matrix.
t : print the transpose of the matrix.
Constraints
Use class and switch to implement.
Output Format
You must output the result after doing the calculation.
E.g. + 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 6 6 6 means
Sample Input
7
p123456789
p100010001
+111222333444555666
+ -1 -1 -1 2 2 2 3 3 3 4 4 4 -5 -5 -5 6 6 6
* 5 -7 14 1 5 -2 -6 -21 4 0 0 0 0 0 0 0 0 0
* 1 2 1 2 4 2 1 2 1 -3 0 2 9 -5 11 -1 -4 8
t 789456123
Sample Output
[1, 2, 3, 4, 5, 6, 7, 8, 9]
[1, 0, 0, 0, 1, 0, 0, 0, 1]
[5, 5, 5, 7, 7, 7, 9, 9, 9]
[3, 3, 3, -3, -3, -3, 9, 9, 9]
[0, 0, 0, 0, 0, 0, 0, 0, 0]
[14, -14, 32, 28, -28, 64, 14, -14, 32]
[7, 4, 1, 8, 5, 2, 9, 6, 3]