Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
class SORT{T < $IS_LT{T}} is
|
||||
|
||||
private swap(inout a, inout b:T) is
|
||||
temp ::= a;
|
||||
a := b;
|
||||
b := temp;
|
||||
end;
|
||||
|
||||
-- ---------------------------------------------------------------------------------
|
||||
comb_sort(inout a:ARRAY{T}) is
|
||||
gap ::= a.size;
|
||||
swapped ::= true;
|
||||
loop until!(gap <= 1 and ~swapped);
|
||||
if gap > 1 then
|
||||
gap := (gap.flt / 1.25).int;
|
||||
end;
|
||||
i ::= 0;
|
||||
swapped := false;
|
||||
loop until! ( (i + gap) >= a.size );
|
||||
if (a[i] > a[i+gap]) then
|
||||
swap(inout a[i], inout a[i+gap]);
|
||||
swapped := true;
|
||||
end;
|
||||
i := i + 1;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
class MAIN is
|
||||
main is
|
||||
a:ARRAY{INT} := |88, 18, 31, 44, 4, 0, 8, 81, 14, 78, 20, 76, 84, 33, 73, 75, 82, 5, 62, 70|;
|
||||
b ::= a.copy;
|
||||
SORT{INT}::comb_sort(inout b);
|
||||
#OUT + b + "\n";
|
||||
end;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue