Problem 4: Transpose a Matrix
Write a program to transpose a given matrix. For example,
Credit: http://www.mathsisfun.com/algebra/matrix-introduction.html
Input
The first line of input contains M the number of cases and then M*2 lines follow. Each
subsequent line consists of cases. Each case has two lines. The first line contains two numbers
represent number of rows and columns. The second line contains list of numbers in twodimensional matrix. For example, the input of
23
6 4 24 1 -9 8
The first line contains 2 and 3 means the input matrix has two rows and three columns. The
second line contains the list of value 6 4 24 1 -9 8 means that they are contained in the matrix
of two rows and three columns as:
{
{6, 4, 24},
{1, -9, 8,}
}
Output
The output should express the transposed matrix in the form of two-dimensional arrays. It
should consist of two lines. The first line contains number of row and column and the second
line contains list of values. The output should be in form of:
Case #1
Number of row and column of the result of case #1
List of value of case#1
Case #2
Number of row and column of the result of case #2
List of value of case#2
Case #M
Number of row and column of the result of case #M
List of value of case#M
Sample Input
3
23
6 4 24 1 -9 8
32
123456
23
-1 7 8 2 3 -4
Sample Output
Case #1
6 1 4 -9 24 8
Case #2
135246
Case #3
-1 2 7 3 8 -4