0% found this document useful (0 votes)
57 views2 pages

Transposing a Matrix Program

The document describes a problem to write a program that takes a matrix as input with the number of rows and columns on the first line and values on the second line. It then outputs the transposed matrix with the number of rows and columns swapped and values in the corresponding positions. The input and output are formatted with case numbers, row/column specifications, and values arranged appropriately.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views2 pages

Transposing a Matrix Program

The document describes a problem to write a program that takes a matrix as input with the number of rows and columns on the first line and values on the second line. It then outputs the transposed matrix with the number of rows and columns swapped and values in the corresponding positions. The input and output are formatted with case numbers, row/column specifications, and values arranged appropriately.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like