-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransposeMatrix.cpp
More file actions
37 lines (36 loc) · 857 Bytes
/
Copy pathTransposeMatrix.cpp
File metadata and controls
37 lines (36 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
using namespace std;
int main(){
int r,c,i,j;
cout << "Enter row number: ";
cin >> r;
cout << "Enter column number: ";
cin >> c;
int array1[r][c], array2[r][c];
cout << "Enter array: ";
for(i = 0; i<r; i++){
for(j = 0; j<c; j++){
cin >> array1[i][j];
}
}
cout << "Initial Matrix: " << endl;
for(i = 0; i<r; i++){
for(j = 0; j<c; j++){
cout << array1[i][j] << " ";
}
cout << endl;
}
for(i = 0; i<r; i++){
for(j = 0; j<c; j++){
array2[j][i] = array1[i][j];
}
}
cout << "Transpose Matrix: " << endl;
for(i = 0; i<r; i++){
for(j = 0; j<c; j++){
cout << array2[i][j] << " ";
}
cout << endl;
}
return 0;
}