Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,43 @@
Section Header
+ name := BUBBLE_SORT;
- external := `#include <time.h>`;
Section Public
- main <- (
+ a : ARRAY(INTEGER);
a := ARRAY(INTEGER).create 0 to 100;
`srand(time(NULL))`;
0.to 100 do { i : INTEGER;
a.put `rand()`:INTEGER to i;
};
bubble a;
a.foreach { item : INTEGER;
item.print;
'\n'.print;
};
);
- bubble a : ARRAY(INTEGER) <- (
+ lower, size, t : INTEGER;
+ sorted : BOOLEAN;
lower := a.lower;
size := a.upper - lower + 1;
{
sorted := TRUE;
size := size - 1;
0.to (size - 1) do { i : INTEGER;
(a.item(lower + i + 1) < a.item(lower + i)).if {
t := a.item(lower + i + 1);
a.put (a.item(lower + i)) to (lower + i + 1);
a.put t to (lower + i);
sorted := FALSE;
};
};
}.do_while {!sorted};
);