===== PascalABC.NET =====
procedure SortShell<T>(a: array of T);
where T: IComparable<T>;
// сортировка по Шеллу
begin
var n := a.Length;
var d := n div 2;
while d > 0 do
var k := True;
while k do
k := False;
for var i := 0 to n - d - 1 do
if a[i].CompareTo(a[i + d]) > 0 then begin
Swap(a[i], a[i + d]);
k := True
end
end;
d := d div 2
var a := ArrRandom(10, -20, 20); a.Println;
SortShell(a); a.Println
end.
===== PascalABC.NET =====
procedure SortShell<T>(a: array of T);
where T: IComparable<T>;
// сортировка по Шеллу
begin
var n := a.Length;
var d := n div 2;
while d > 0 do
begin
var k := True;
while k do
begin
k := False;
for var i := 0 to n - d - 1 do
if a[i].CompareTo(a[i + d]) > 0 then begin
Swap(a[i], a[i + d]);
k := True
end
end;
d := d div 2
end
end;
begin
var a := ArrRandom(10, -20, 20); a.Println;
SortShell(a); a.Println
end.