include iostream using namespace std const int 10 template typename So

 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
#include <iostream>
using namespace std;
const int F = 10;
template <typename T>
T Sort(T *a, int sizee ){
int left = 1;
int right = sizee - 1;
int i=1, j=2;
T tmp,k;
while (left <= right)
{
for ( i = right; i >= left; i--)
if (a[i - 1] > a[i]) {
tmp=a[i];
a[i]=a[i-1];
a[i-1]=tmp;
}
left++;
for ( i = left; i <= right; i++)
if (a[i - 1] > a[i])
{
tmp=a[i];
a[i]=a[i-1];
a[i-1]=tmp;
}
right--;
}
while (i<sizee && a[i]<0 ){
if(a[i-1]<=a[i]){
i=j;
j++;
}
else{
tmp=a[i];
a[i] = a[i-1];
a[i-1] = tmp;
i--;
if (i==0) {
i=j;
j++; }
}
};
}
int main()
{
int i;
double c[F];
cout << "Vvedite massiv double: " << endl;
for( i = 0; i < F; i++)
cin >> c[i];
cout << "Poluchennyi massiv double: " << endl;
Sort<double>( c, F);
for( i = 0; i < F; i++)
cout << c[i] << endl;
char b[F];
cout << "Vvedite massiv char: " << endl;
for(i = 0; i < F; i++)
cin >> b[i];
cout << "Poluchennyi massiv char: " << endl;
Sort<char>( b, F);
for(i = 0; i < F; i++)
cout << b[i] << endl;
return 0;
}