home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disc 35 / Commodore_Disc_35_19xx_-_de.d64 / turbosort.int (.txt) < prev   
Commodore BASIC  |  2022-10-26  |  792b  |  28 lines

  1. 100 input"anzahl der werte";d:print
  2. 110 dim e%(d),a%(d),l%(16),r%(16)
  3. 120 fori=1tod:e%(i)=int(rnd(1)*32768):a%(i)=e%(i):next
  4. 130 at=ti:gosub 190:at=ti-at
  5. 140 fori=1tod:printe%(i),a%(i):next
  6. 150 print:printat:end
  7. 160 rem ------------------------------
  8. 170 rem   turbosort integer
  9. 180 rem ------------------------------
  10. 190 l%(1)=1:r%(1)=d:eb=1:goto260
  11. 200 ifl>=rthen250
  12. 210 forj=rtol+1step-1:vw=a%(j-1):a=r:fori=jtor
  13. 220 ifa%(i)>=vwthena=i-1:i=r:goto240
  14. 230 a%(i-1)=a%(i)
  15. 240 nexti:a%(a)=vw:nextj
  16. 250 eb=eb-1:ifeb=0thenreturn
  17. 260 l=l%(eb):r=r%(eb):ifl+12>rthen200
  18. 270 vw=a%(int((l+r)/2))
  19. 280 ifa%(l)<vw then l=l+1:goto280
  20. 290 ifa%(r)>vw then r=r-1:goto290
  21. 300 ifl>r then 330
  22. 310 a=a%(l):a%(l)=a%(r):a%(r)=a
  23. 320 l=l+1:r=r-1:ifl<=r then 280
  24. 330 eb=eb+1
  25. 340 if(r-l%(eb-1))<(r%(eb-1)-l)thenl%(eb)=l%(eb-1):r%(eb)=r:l%(eb-1)=l:goto260
  26. 350 l%(eb)=l:r%(eb)=r%(eb-1):r%(eb-1)=r:goto260
  27. 360 rem ------------------------------
  28.