-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwo_dim_arrays_11.cpp
64 lines (56 loc) · 1.37 KB
/
two_dim_arrays_11.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
using namespace std;
int main()
{
int m, n;
cout << "Enter Row of Matrix : " << endl;
cin >> m;
cout << "Enter Column of Matrix : " << endl;
cin >> n;
int mat[m][n];
int transpose[m][n];
cout << "Enter elements in the Matrix: " << endl;
cout << "\n";
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
cout << "mat[" << i << "][" << j << "] = ";
cin >> mat[i][j];
}
}
cout << "\n";
cout << " Representation of Matrix :(m x n) :" << endl;
cout << "\n";
for (int i = 0; i < m; i++)
{
cout << "|";
for (int j = 0; j < n; j++)
{
cout << mat[i][j] << " ";
}
cout << "|";
cout << endl;
}
cout << " Transpose of 2D matrix in :(m x n) : initiating...." << endl;
for (int i = 0; i < m; i++)
{
for (int j = 0; j < n; j++)
{
transpose[j][i] = mat[i][j];
}
}
cout << " Representation of Transposed Matrix :(m x n) :" << endl;
cout << "\n";
for (int i = 0; i < m; i++)
{
cout << "|";
for (int j = 0; j < n; j++)
{
cout << transpose[i][j] << " ";
}
cout << "|";
cout << endl;
}
return 0;
}