Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,36 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
string 0; \use zero-terminated strings
|
||||
|
||||
|
||||
proc SSort(A, N); \Shell sort array in ascending order
|
||||
char A; \address of array
|
||||
int N; \number of elements in array (size)
|
||||
int I, J, Gap, JG, T;
|
||||
[Gap:= N>>1;
|
||||
while Gap > 0 do
|
||||
[for I:= Gap to N-1 do
|
||||
[J:= I - Gap;
|
||||
loop [JG:= J + Gap;
|
||||
if A(J) <= A(JG) then quit;
|
||||
T:= A(J); A(J):= A(JG); A(JG):= T; \swap elements
|
||||
J:= J - Gap;
|
||||
if J < 0 then quit;
|
||||
];
|
||||
];
|
||||
Gap:= Gap>>1;
|
||||
];
|
||||
]; \SSort
|
||||
|
||||
|
||||
func StrLen(Str); \Return number of characters in an ASCIIZ string
|
||||
char Str;
|
||||
int I;
|
||||
for I:= 0 to -1>>1-1 do
|
||||
if Str(I) = 0 then return I;
|
||||
|
||||
|
||||
char Str;
|
||||
[Str:= "Pack my box with five dozen liquor jugs.";
|
||||
SSort(Str, StrLen(Str));
|
||||
Text(0, Str); CrLf(0);
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue