Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
class SORT{T < $IS_LT{T}} is
|
||||
private swap(inout a, inout b:T) is
|
||||
temp ::= a;
|
||||
a := b;
|
||||
b := temp;
|
||||
end;
|
||||
bubble_sort(inout a:ARRAY{T}) is
|
||||
i:INT;
|
||||
if a.size < 2 then return; end;
|
||||
loop
|
||||
sorted ::= true;
|
||||
loop i := 0.upto!(a.size - 2);
|
||||
if a[i+1] < a[i] then
|
||||
swap(inout a[i+1], inout a[i]);
|
||||
sorted := false;
|
||||
end;
|
||||
end;
|
||||
until!(sorted);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
class MAIN is
|
||||
main is
|
||||
a:ARRAY{INT} := |10, 9, 8, 7, 6, -10, 5, 4|;
|
||||
SORT{INT}::bubble_sort(inout a);
|
||||
#OUT + a + "\n";
|
||||
end;
|
||||
end;
|
||||
Loading…
Add table
Add a link
Reference in a new issue