-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArray32.cpp
More file actions
148 lines (133 loc) · 3.03 KB
/
Copy pathArray32.cpp
File metadata and controls
148 lines (133 loc) · 3.03 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
void InverseIndx(int matrix[32][32], int row, int col, int U)
{
int B[(row * col) * ((row * col) + 1) / 2];
int i, j;
int x = 0; //counter value
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
B[x] = matrix[i][j];
++x;
}
}
cout << "Elements In Array" << endl;
for (i = 0; i < x; i++)
{
cout << B[i] << ", ";
}
cout << endl;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if (matrix[i][j] == B[U])
{
cout << "Index of"
<< " " << B[U] << " "
<< "In The Matrix Is"
<< " "
<< "(" << i << "," << j << ")" << endl;
}
}
}
}
int main()
{
int k = 0;
int A[32][32];
int row = 32, col = 32;
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
A[i][j] = rand() % 1000 + 1;
;
}
}
int size = row * col;
int B[size];
int C[10][10];
int i, j;
int x = 0;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if (i < j)
{
cout << " "
<< " ";
}
else
{
cout << A[i][j] << " ";
B[x] = A[i][j];
C[i][j] = B[x];
++x;
}
}
cout << endl;
}
cout << endl;
cout << "The first 20 values of the lower trinagular elements of A[32][32]:";
for (i = 0; i < 20; i++)
{
cout << B[i] << " ";
}
cout << endl;
for (i = 0; i < row; i++)
{
for (j = 0; j < col; j++)
{
if (A[i][j] == B[k] && k != 20)
{
cout << "Index of"
<< " " << B[k] << " "
<< "In The Matrix Is"
<< " "
<< "(" << i << "," << j << ")" << endl;
++k;
};
}
}
cout << endl;
cout << "The first 20 elements of B[] and their respective indices;" << endl;
for (i = 0; i < 20; i++)
{
cout << "Index of"
<< " " << B[i] << " "
<< "In The Array Is"
<< " " << i << endl;
}
cout << endl;
cout << endl;
int h = 0;
int rowl = 10;
int coll = 10;
for (i = 0; i < rowl; i++)
{
for (j = 0; j < coll; j++)
{
C[i][j] = B[h++];
}
}
cout << endl;
cout << "The first 20 elements of C[][] and their respective indices;" << endl;
for (i = 0; i < 2; i++)
{
for (j = 0; j < 10; j++)
{
cout << "Index of"
<< " " << C[i][j] << " "
<< "In The Matrix Is"
<< " "
<< "(" << i << "," << j << ")" << endl;
}
}
}