Question: Problem B: Flip Array You are given several 2D arrays (matrices) of integers at the input. You must write a program to flip each array

Problem B: Flip Array You are given several 2D arrays (matrices) of integers at the input. You must write a program to flip each array around the main diagonal; i.e., to print out the transposed matrix. For example, if a 2 3 array is given as follows: 1 2 3 -4 -5 0 you must produce the following transposed matrix 3 2: 1 -4 2 -5 3 0 Several matrices can be given in the standard input. Input The input consists of a sequence of matrices. Each matrix starts with two positive integers n and m, which specify the number of rows and columns of the matrix, followed by all numbers in the matrix, organized by rows and columns. The end of input is marked by two zeros. Output For each input matrix, you must print the same matrix, but transposed. First, you must print the dimensions of the transposed matrix, which are obviously swapped dimensions of the input matrix. These two numbers must be separated by a space and that is the only space on this line. After that, you need to print all rows of the transposed matrix. Print one space before printing each number, so that the numbers in each row are separated. This means that there will be one space at the very beginning of each row. After printing a matrix, print one empty line in order to separate the matrix from the next one. Again, this means that there will be an empty line after the last matrix as well. Check the sample input and output and make sure that program produced output in the exact expected format.

Problem B: Flip Array You are given several 2D arrays (matrices) of

Sample Input|Sample Output|Sample Output, with visualized whitespace 1 -4 2-5 1 2 3 1-4 4-50

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!