-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path#07 (3) - Traspose Matrix.txt
More file actions
55 lines (46 loc) · 1.06 KB
/
Copy path#07 (3) - Traspose Matrix.txt
File metadata and controls
55 lines (46 loc) · 1.06 KB
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
#include<iostream>
#include<iomanip>
using namespace std;
void FillMatrixWithOrderedNumbers(short Arr[3][3], short Rows, short Columns)
{
short Counter = 1;
for (short i = 0;i < Rows;i++)
{
for (short j = 0;j < Columns;j++)
{
Arr[i][j] = Counter++;
}
}
}
void TransposeMatrix(short Arr[3][3], short ArrTransposed[3][3], short Rows, short Columns)
{
for (short i=0;i<Rows;i++)
{
for (short j = 0;j < Columns;j++)
{
ArrTransposed[i][j] = Arr[j][i];
}
}
}
void PrintMatrix(short Arr[3][3], short Rows, short Columns)
{
for (short i = 0;i < Rows;i++)
{
for (short j = 0;j < Columns;j++)
{
cout << setw(3) << Arr[i][j] << "\t";
}
cout << endl;
}
}
int main()
{
short Array[3][3], TransposedMatrix[3][3];
FillMatrixWithOrderedNumbers(Array, 3, 3);
cout << "The Following is a 3x3 Ordered Matrix :\n";
PrintMatrix(Array, 3, 3);
TransposeMatrix(Array, TransposedMatrix, 3, 3);
cout << "\nThe Following is the transposed Matrix :\n";
PrintMatrix(TransposedMatrix, 3, 3);
return 0;
}