Multiplying Matrices
Write a program to compute the product of two matrices A and B that are multipliable in the form of AB.
Input
The first line of input is the number of all the test cases that follow. For each test case, there are three positive integer m, n, p (m, n, p <= 100) on the first line, meaning that A's dimension is m rows by n columns while B's is n rows by p columns. Then comes the data of matrices A and B. Matrix A is represented by m lines of integers ranging in [-1000, 1000], with each line containing n integers separated by a space. A line is corresponding to a row of a matrix. The data format for matrix B is much the same except for its potentially different dimensions. Please refer to the section Sample Input.
Output
For each test case, print the product of A multiplied by B in the form described in the section Input, but do not include any dimension description.
Sample Input
2
2 2 2
1 2
3 4
1 2
3 4
1 2 1
1 0
0
1
Sample Output
7 10
15 22
0
使用动态内存分配(malloc()和free())完成。
[此贴子已经被作者于2006-12-3 15:34:20编辑过]