Problem

2 /12


Filling the matrix from the keyboard

Theory Click to read/hide

Filling a matrix with values ​​from the keyboard.

Let the program receive a two-dimensional array as input, in the form n strings, each containing m numbers separated by spaces. How to count them? For example, like this:

int[,] array = new int[n,m]; // create an array to populate
for (int i = 0; i <  n; i++)
{
       string A = Console.ReadLine(); // read line
       int[] curr = A.Split(' ').Select(int.Parse).ToArray(); // convert this string to a one-dimensional array curr
       for (int j = 0; j < m; j++)
       {
           array[i, j] = curr[j]; // fill in the string of the array we need with the values ​​from the curr array
       }
}

 

Problem

Write a program that displays transposed< em> matrix. Matrix transposition is a  transformation where rows become columns and – lines. The matrix itself does not need to be changed. It is enough to display it in the desired form.

Input data: the first line contains space-separated matrix dimensions: number of rows  ;and number of columns ( 1 ≤ M < /em>≤ 100 ). The following lines contain matrix rows, each – by natural numbers separated by spaces.

Output: the program should output a matrix that would result as a result of row-wise transposition.

Example.
# Input Output
1 4 5
1 2 3 4 5
6 7 8 9 3
5 4 3 2 1
7 9 8 7 6
1 6 5 7
2 7 4 9
3 8 3 8
4 9 2 7
5 3 1 6