Transpose of Matrix
Lesson 17 of 26 in Coddy's Arrays in C++ course.
Challenge
Given a 2D array, prints the transposed 2D array.
Transpose of the matrix: The transpose of a matrix is found by interchanging its rows into columns and columns into rows.
For example:
input:
[[1,2,3],
[4,5,6],
[7,8,9]]
Output:
[[1,4,7],
[2,5,8],
[3,6,9]]
To know more about what is the transpose
Try it yourself
#include<iostream>
using namespace std;
int main(){
int m,n;
cin>>m>>n;
int arr[m][n];
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>arr[i][j];
}
}
//Code here
return 0;
}
All lessons in Arrays in C++
7Array Challenges
Reverse an ArraySmallest Positive MissingTranspose of MatrixAddition of Two MatrixMax and Min ElementCheck Palindrome2Memory Analysis
Memory Allocation