home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disc 35
/
Commodore_Disc_35_19xx_-_de.d64
/
turbo-sort.txt
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
876b
|
30 lines
100 dim e$(10),a$(10),l%(16),r%(16)
110 data"ram","monitor","floppy","disc","rom","computer","tasten","joystick","drucker","basic"
120 fori=1to10:reade$(i):next
130 d=10
140 fori=1tod:a$(i)=e$(i):next
150 at=ti:gosub 210:at=ti-at
160 fori=1tod:printe$(i),a$(i):next
170 print:printat:end
180 rem ------------------------------
190 rem turbosort text
200 rem ------------------------------
210 l%(1)=1:r%(1)=d:eb=1:goto280
220 ifl>=rthen270
230 forj=rtol+1step-1:vw$=a$(j-1):a=r:fori=jtor
240 ifvw$<=a$(i)thena=i-1:i=r:goto260
250 a$(i-1)=a$(i)
260 nexti:a$(a)=vw$:nextj
270 eb=eb-1:ifeb=0thenreturn
280 l=l%(eb):r=r%(eb):if l+12>r then 220
290 vw$=a$(int((l+r)/2))
300 ifa$(l)<vw$ then l=l+1:goto300
310 ifa$(r)>vw$ then r=r-1:goto310
320 ifl>r then 350
330 a$=a$(l):a$(l)=a$(r):a$(r)=a$
340 l=l+1:r=r-1:ifl<=r then 300
350 eb=eb+1
360 if(r-l%(eb-1))<(r%(eb-1)-l)thenl%(eb)=l%(eb-1):r%(eb)=r:l%(eb-1)=l:goto280
370 l%(eb)=l:r%(eb)=r%(eb-1):r%(eb-1)=r:goto280
380 rem ------------------------------