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,28 @@
code ChOut=8, IntOut=11;
proc CocktailSort(A, L); \Sort array A of length L
int A, L;
int Swapped, I, T;
[loop [Swapped:= false;
for I:= 0 to L-2 do
if A(I) > A(I+1) then \test if elements are in wrong order
[T:= A(I); A(I):= A(I+1); A(I+1):= T; \elements change places
Swapped:= true;
];
if Swapped = false then quit; \exit outer loop if no swaps occurred
Swapped:= false;
for I:= L-2 downto 0 do
if A(I) > A(I+1) then
[T:= A(I); A(I):= A(I+1); A(I+1):= T;
Swapped:= true;
];
\if no elements have been swapped then the list is sorted
if not Swapped then quit;
];
];
int A, I;
[A:= [3, 1, 4, 1, -5, 9, 2, 6, 5, 4];
CocktailSort(A, 10);
for I:= 0 to 10-1 do [IntOut(0, A(I)); ChOut(0, ^ )];
]