forked from ISUCT/Exam_1_42
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Varvara_Troshina_var5.cpp
69 lines (58 loc) · 997 Bytes
/
Varvara_Troshina_var5.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
66
67
68
69
#include <iostream>
using namespace std;
class massive
{
private:
int size;
public:
massive(int s)
{
size = s;
int* l = new int[size];
cout << endl << "enter massive:" << endl;
for (int i = 0; i < size; ++i) {
cout << "a[" << i << "]=";
cin >> l[i];
}
quick_sort(l, 0, size - 1);
int k = 1;
for (int i = size - 1; i > size - 3; --i) {
k = k * l[i];
cout << endl << "a[" << i << "]=" << l[i] << " —-max" << endl;
}
cout << endl << "Proizvedenie max =" << k << endl;
}
void quick_sort(int* a, int min, int max) {
int i = min;
int j = max;
int x = a[(min + max) / 2];
int t;
do {
while (a[i] < x) {
++i;
}
while (a[j] > x) {
--j;
}
if (i <= j) {
t = a[i];
a[i] = a[j];
a[j] = t;
i++; j--;
}
} while (i <= j);
if (min < j) {
quick_sort(a, min, j);
};
if (i < max) {
quick_sort(a, i, max);
}
}
};
int main()
{
int size;
cout << "enter size:";
cin >> size;
massive massive(size);
}