home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Disc 35
/
Commodore_Disc_35_19xx_-_de.d64
/
turbosort.int
(
.txt
)
< prev
Wrap
Commodore BASIC
|
2022-10-26
|
792b
|
28 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 turbosort integer
180 rem ------------------------------
190 l%(1)=1:r%(1)=d:eb=1:goto260
200 ifl>=rthen250
210 forj=rtol+1step-1:vw=a%(j-1):a=r:fori=jtor
220 ifa%(i)>=vwthena=i-1:i=r:goto240
230 a%(i-1)=a%(i)
240 nexti:a%(a)=vw:nextj
250 eb=eb-1:ifeb=0thenreturn
260 l=l%(eb):r=r%(eb):ifl+12>rthen200
270 vw=a%(int((l+r)/2))
280 ifa%(l)<vw then l=l+1:goto280
290 ifa%(r)>vw then r=r-1:goto290
300 ifl>r then 330
310 a=a%(l):a%(l)=a%(r):a%(r)=a
320 l=l+1:r=r-1:ifl<=r then 280
330 eb=eb+1
340 if(r-l%(eb-1))<(r%(eb-1)-l)thenl%(eb)=l%(eb-1):r%(eb)=r:l%(eb-1)=l:goto260
350 l%(eb)=l:r%(eb)=r%(eb-1):r%(eb-1)=r:goto260
360 rem ------------------------------