home *** CD-ROM | disk | FTP | other *** search
/ Commodore Disc 35 / Commodore_Disc_35_19xx_-_de.d64 / turbo-sort.txt (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  876b  |  30 lines

  1. 100 dim e$(10),a$(10),l%(16),r%(16)
  2. 110 data"ram","monitor","floppy","disc","rom","computer","tasten","joystick","drucker","basic"
  3. 120 fori=1to10:reade$(i):next
  4. 130 d=10
  5. 140 fori=1tod:a$(i)=e$(i):next
  6. 150 at=ti:gosub 210:at=ti-at
  7. 160 fori=1tod:printe$(i),a$(i):next
  8. 170 print:printat:end
  9. 180 rem ------------------------------
  10. 190 rem   turbosort text
  11. 200 rem ------------------------------
  12. 210 l%(1)=1:r%(1)=d:eb=1:goto280
  13. 220 ifl>=rthen270
  14. 230 forj=rtol+1step-1:vw$=a$(j-1):a=r:fori=jtor
  15. 240 ifvw$<=a$(i)thena=i-1:i=r:goto260
  16. 250 a$(i-1)=a$(i)
  17. 260 nexti:a$(a)=vw$:nextj
  18. 270 eb=eb-1:ifeb=0thenreturn
  19. 280 l=l%(eb):r=r%(eb):if l+12>r then 220
  20. 290 vw$=a$(int((l+r)/2))
  21. 300 ifa$(l)<vw$ then l=l+1:goto300
  22. 310 ifa$(r)>vw$ then r=r-1:goto310
  23. 320 ifl>r then 350
  24. 330 a$=a$(l):a$(l)=a$(r):a$(r)=a$
  25. 340 l=l+1:r=r-1:ifl<=r then 300
  26. 350 eb=eb+1
  27. 360 if(r-l%(eb-1))<(r%(eb-1)-l)thenl%(eb)=l%(eb-1):r%(eb)=r:l%(eb-1)=l:goto280
  28. 370 l%(eb)=l:r%(eb)=r%(eb-1):r%(eb-1)=r:goto280
  29. 380 rem ------------------------------
  30.