071502 - Matrix operations
題目敘述 Problems Description:
請寫一個程式可以輸入一個任意大小的矩陣,並具備以下功能:
Please write a program that can input a matrix of any size and has the following functions:
Change the shape of the matrix
Multiply the matrix (If the input matrix cannot be multiplied ,then output “fail”)
首先輸入矩陣的大小、矩陣中的值,最後重複輸入功能代號,且輸入的值皆為整數。
Input the size of the matrix and the values in the matrix. Then keep input the request number. By the way, it always inputs integers.
輸出說明 Output Description:
先輸出request:,然後再輸出對應功能代號的結果。
First, print request:, and then output the result of the corresponding request number.
2 3
1 2 3
1 1 1
1
3 2
4
2
2 3
1 1 1
1 1 1
4
2
2 3
2 2 2
2 2 2
3
4
5
輸出範例 Output Example:
request:
request:
[[1 2]
[3 1]
[1 1]]
request:
request:
[[3 3 3]
[4 4 4]
[2 2 2]]
request:
fail
request:
request:
[[3 4 2]
[3 4 2]
[3 4 2]]
request: