program sorting;
const
N = 10;
var
v: array[1..N] of integer;
d: integer;
i, t: integer;
k: boolean;
begin
randomize;
write('ДО сортировки: ');
for i := 1 to N do
readln(v[i])
write(v[i]:6);
end;
}
d := N div 2;
while(d > 0) do
k := true;
while k do
k := false;
i := 1;
for i := 1 to N - d do
if(v[i] > v[i + d]) then
t := v[i];
v[i] := v[i + d];
v[i + d] := t;
d := d div 2;
writeln;
write('ПОСЛЕ сортировки: ');
end.
program sorting;
const
N = 10;
var
v: array[1..N] of integer;
d: integer;
i, t: integer;
k: boolean;
begin
randomize;
write('ДО сортировки: ');
for i := 1 to N do
begin
readln(v[i])
write(v[i]:6);
end;
}
d := N div 2;
while(d > 0) do
begin
k := true;
while k do
begin
k := false;
i := 1;
for i := 1 to N - d do
begin
if(v[i] > v[i + d]) then
begin
t := v[i];
v[i] := v[i + d];
v[i + d] := t;
k := true;
end;
end;
end;
d := d div 2;
end;
writeln;
write('ПОСЛЕ сортировки: ');
for i := 1 to N do
write(v[i]:6);
writeln;
end.