home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disc 35
/
Commodore_Disc_35_19xx_-_de.d64
/
quick-sort.int
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
682b
|
23 lines
100 input"anzahl der werte";d:print
110 dim e%(d),a%(d),l%(16),r%(16)
120 fori=1tod:e%(i)=int(rnd(1)*32768):a%(i)=e%(i):next
130 at=ti:gosub 190:at=ti-at
140 fori=1tod:printe%(i),a%(i):next
150 print:printat:end
160 rem ------------------------------
170 rem quicksort 128 integer
180 rem ------------------------------
190 l%(1)=1:r%(1)=d:eb=2
200 eb=eb-1:ifeb=0thenreturn
210 if l%(eb)>=r%(eb) then 200
220 l=l%(eb):r=r%(eb):vw=a%(int((l+r)/2))
230 if a%(l)<vw then l=l+1:goto230
240 ifa%(r)>vw then r=r-1:goto240
250 ifl>r then 280
260 a=a%(l):a%(l)=a%(r):a%(r)=a
270 l=l+1:r=r-1:ifl<=rthen230
280 eb=eb+1
290 if(r-l%(eb-1))<(r%(eb-1)-l)thenl%(eb)=l%(eb-1):r%(eb)=r:l%(eb-1)=l:goto210
300 l%(eb)=l:r%(eb)=r%(eb-1):r%(eb-1)=r:goto210
310 rem ------------------------------