Write a function to find the transpose of a 2x3 matrix {{1, 2, 3}, {4, 5, 6}}.
MediumProblem Statement
Write a function to find the transpose of a 2x3 matrix {{1, 2, 3}, {4, 5, 6}}.
Sample Input
Matrix: 1 2 3 4 5 6
Sample Output
1 4 2 5 3 6
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <stdio.h>
void transposeMatrix(int matrix[2][3], int transposed[3][2]) {
// Your code here
}
int main() {
int matrix[2][3] = {{1, 2, 3}, {4, 5, 6}};
int transposed[3][2];
transposeMatrix(matrix, transposed);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
printf("%d ", transposed[i][j]);
}
printf("\n");
}
return 0;
}
Input
Matrix: 1 2 3 4 5 6
Expected Output
1 4 2 5 3 6