-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtranspose_array_function.cpp
65 lines (47 loc) · 1.01 KB
/
transpose_array_function.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
65
#include <iostream>
using namespace std;
//Sharif Ullah Danish
void transpose1(int a[5][5], int transpose[5][5], int r, int c, int i, int j);
int main()
{
int a[5][5], transpose[5][5], r, c, i, j;
cout<<"Enter Rows & Columns: ";
cin>>r>>c;
cout<<"\n Enter elements of matrix: ";
for(i=0; i<r; ++i)
for(j=0; j<c; ++j)
{
cout<<"Enter matrix "<<"["<<i+1<<"]"<<"["<<j+1<<"]: ";
cin>>a[i][j];
}
transpose1(transpose, a);
return 0;
}
void transpose1( int a[5][5], int transpose[5][5], int r, int c, int i, int j)
{
cout<<"\n\n Your matrix is below: \n ";
for(i=0; i<r; ++i)
for(j=0; j<c; ++j)
{
cout<<" "<< a[i][j];
if( j == c - 1 )
cout << endl << endl;
}
for(i=0; i<r; ++i)
{
for(j=0; j<c; ++j)
{
transpose[j][i] = a[i][j];
}
}
cout<<"Transpose is: \n";
for(i=0; i<c; ++i)
{
for(j=0; j<r; ++j)
{
cout<<" "<<transpose[i][j];
if(j == r - 1)
cout<<endl<<endl;
}
}
}