Suppose you have a Go program that takes as an input various int numbers and generates a 3x3 matrix A using the hidden generateMatrix() function.
Your task is to transpose the A matrix. To do this, you need to declare and initialize a new 3x3 matrix variable transposedA with the transposed version of matrix A and then print each row of the transposedA matrix.
The transpose of a matrix is an operation that flips a matrix over its diagonal; it switches the row and column indices of the matrix. Below is an example of declaring and initializing the transposed version of the 2x2 matrix
B:
var B = [2][2]int{
{1, 2},
{3, 4},
}
var transposedB = [2][2]int{
{B[0][0], B[1][0]},
{B[0][1], B[1][1]},
}
fmt.Println(transposedB[0])
fmt.Println(transposedB[1])
// Output:
// [1 3]
// [2 4]