home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disc 35
/
Commodore_Disc_35_19xx_-_de.d64
/
quick-sort.txt
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
757b
|
25 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 quicksort text
200 rem ------------------------------
210 l%(1)=1:r%(1)=d:eb=2
220 eb=eb-1:ifeb=0thenreturn
230 if l%(eb)>=r%(eb) then 220
240 l=l%(eb):r=r%(eb):vw$=a$(int((l+r)/2))
250 ifa$(l)<vw$ then l=l+1:goto250
260 ifa$(r)>vw$ then r=r-1:goto260
270 ifl>r then 300
280 a$=a$(l):a$(l)=a$(r):a$(r)=a$
290 l=l+1:r=r-1:ifl<=r then 250
300 eb=eb+1
310 if(r-l%(eb-1))<(r%(eb-1)-l)thenl%(eb)=l%(eb-1):r%(eb)=r:l%(eb-1)=l:goto230
320 l%(eb)=l:r%(eb)=r%(eb-1):r%(eb-1)=r:goto230
330 rem ------------------------------