home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug006.arc
/
DATASORT.DOC
< prev
next >
Wrap
Text File
|
1979-12-31
|
3KB
|
67 lines
TH┼ SORTIN╟ O╞ DAT┴ LISTS
┴á practica∞ usσ fo≥ thσ Microbeσ i≤ thσ sortinτ anΣ manipulatinτ oµá data¼ ì
sucΦá a≤á thσ namσ anΣ addres≤ lis⌠ fo≥ ß smal∞ club¼á o≥á thσá progressivσ ì
result≤á oµá ßá loca∞á sport≤ club«á Thσ datß i≤ usuall∙ storeΣá iεá ßá tw∩ ì
dimensioε arra∙ o≥ ß concatenateΣ singlσ dimensioε array«á ┴ 32δá Microbeσ ì
caεá handlσá 10░ o≥ 20░ line≤ oµ datß iε thi≤ form«á Thσ numbe≥á oµá line≤ ì
dependinτ oε thσ compactnes≤ oµ thσ data.
Onσá oµá thσá bes⌠ way≤ oµ sortinτ thi≤ datß i≤ t∩ usσá thσá Shel∞á sortinτ ì
method«á Fo≥á ß hundreΣ o≥ s∩ number≤ i⌠ i≤ a≤ fas⌠ a≤ Quicksort¼á anΣ thσ ì
Shellsor⌠ routinσ use≤ les≤ memory« Thσ Shellsor⌠ subroutinσ showε herσ i≤ ì
se⌠ u≡ fo≥ Rea∞ number≤ iε ascendinτ orde≥ a≤ woulΣ bσ useΣ fo≥ thσ result≤ ì
oµ ß golµ serie≤ o≥ yach⌠ racσ series.
0025░ RE═ Sorting
0026░ U=N
0027░ U=U/2
0028░ I╞ U=░ THE╬ RETURN
0029░ W=1║ V=N-U
0030░ I=W
0031░ Q=I+U
0032░ I╞ S0(I)<S0(Q⌐ THE╬ 370
0033░ Z2=S0(I)║ S0(I)=S0(Q)║ S0(Q)=Z2
0034░ I=I-U
0035░ I╞ I<▒ THE╬ 370
0036░ GOT╧ 310
0037░ W=W+1║ I╞ ╫ <=╓ THE╬ 300
0038░ GOT╧ 270
Fo≥ ß descendinτ sor⌠ reversσ thσ arro≈ heaΣ iε linσ 320«á Fo≥ ß permanen⌠ ì
sort¼ movinτ al∞ thσ element≤ iε eacΦ linσ oµ ß tw∩ dimensioε array¼ inser⌠ ì
additiona∞ line≤ simila≥ t∩ linσ 330¼ (afte≥ linσ 330,⌐ fo≥ eacΦ elemen⌠ iε ì
thσ row.
Iµá thσá sor⌠ i≤ t∩ bσ temporary¼á fo≥ displayinτ o≥ printinτá ou⌠á ßá lis⌠ ì
withou⌠ disturbinτ thσ origina∞ array¼ thσ followinτ routinσ caε bσ used.
0010░ RE═ Dimensioε ª initialisσ array
0011░ N=50
0012░ DI═ S0(N)¼ A0(N,3)¼ F(N)║ STRS(1500)
0013░ FO╥ I=▒ T╧ N║ A0$(I,1)=""║ NEX╘ I
0014░ GOT╧ -----╛ YOU╥ MAI╬ PROGRAM
- - - - - - - - - - - - - -
0150░ RE═ Displa∙ results
0151░ FO╥ I=▒ T╧ N║ S0(I)=A0(I,2)║ NEX╘ I
0152░ GOSU┬ 250
0153░ CLS:PRINT\TAB(17);"YOU╥ TITLE"\
0154░ FO╥ I=▒ T╧ N║ F(I)=0║ NEX╘ I
0155░ FO╥ I=▒ T╧ N║ K=1║ J=1
0156░ I╞ A0(J,2)<>S0(I)║ J=J+1║ GOT╧ 1560
0157░ I╞ F(J)║ J=J+1║ GOT╧ 1560
0158░á PRIN╘á [F8.░ A0(J,0)]╗á A0$(J,1)╗á TAB(25)╗á [F8.▓ A0(J,2)];óá "╗ ì
A0(J,3)
0159░ F(J)=-1
0160░ Z3=FLT((I+4)/15):IFZ3=FLT(I+4)/15:U=USR(32774)
0161░ NEX╘ Iè0162░ PRINT\TAB(26);"EnΣ oµ Data"
Thσ ╞ arra∙ i≤ useΣ t∩ ensurσ tha⌠ thσ ful∞ lis⌠ i≤ printeΣ ou⌠ eveε iµ tw∩ ì
o≥ morσ number≤ arσ thσ same¼á a≤ iε ß tieΣ result«á Linσ 160░ i≤ useΣá s∩ ì
tha⌠á ßá pagσá a⌠ ß timσ i≤ sen⌠ t∩ thσ screeε a⌠ thσ toucΦ oµá ßá key¼á i⌠ ì
allow≤á fo≥ fou≥ line≤ oµ headinτ oε thσ firs⌠ page«á Deletσ thi≤ linσá iµ ì
thσ lis⌠ oµ datß i≤ directeΣ t∩ ß printer. Ro∙ Wilson