all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,28 @@
code ChOut=8, IntOut=11;
proc GnomeSort(A(0..Size-1)); \Sort array A
int A, Size;
int I, J, T;
[I:= 1;
J:= 2;
while I < Size do
if A(I-1) <= A(I) then
[\ for descending sort, use >= for comparison
I:= J;
J:= J+1;
]
else
[T:= A(I-1); A(I-1):= A(I); A(I):= T; \swap
I:= I-1;
if I = 0 then
[I:= J;
J:= J+1;
];
];
];
int A, I;
[A:= [3, 1, 4, 1, -5, 9, 2, 6, 5, 4];
GnomeSort(A, 10);
for I:= 0 to 10-1 do [IntOut(0, A(I)); ChOut(0, ^ )];
]