Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,68 @@
|
|||
DEFINE PTR="CARD"
|
||||
|
||||
PROC PrintArray(PTR ARRAY a BYTE size)
|
||||
BYTE i
|
||||
|
||||
Put('[)
|
||||
FOR i=0 TO size-1
|
||||
DO
|
||||
IF i>0 THEN Put(' ) FI
|
||||
Print(a(i))
|
||||
OD
|
||||
Put(']) PutE()
|
||||
RETURN
|
||||
|
||||
BYTE FUNC IsBefore(CHAR ARRAY a,b)
|
||||
DEFINE NO_KEY="255"
|
||||
DEFINE KEY_Y="43"
|
||||
DEFINE KEY_N="35"
|
||||
BYTE CH=$02FC ;Internal hardware value for last key pressed
|
||||
BYTE k
|
||||
|
||||
PrintF("Is %S before %S (y/n)? ",a,b)
|
||||
CH=NO_KEY ;Flush the keyboard
|
||||
DO
|
||||
k=CH
|
||||
UNTIL k=KEY_Y OR k=KEY_N
|
||||
OD
|
||||
CH=NO_KEY ;Flush the keyboard
|
||||
IF k=KEY_Y THEN
|
||||
PrintE("yes")
|
||||
RETURN (1)
|
||||
FI
|
||||
PrintE("no")
|
||||
RETURN (0)
|
||||
|
||||
PROC InteractiveInsertionSort(PTR ARRAY a BYTE size)
|
||||
INT i,j
|
||||
PTR value
|
||||
|
||||
FOR i=1 TO size-1
|
||||
DO
|
||||
value=a(i)
|
||||
j=i-1
|
||||
WHILE j>=0 AND IsBefore(value,a(j))=1
|
||||
DO
|
||||
a(j+1)=a(j)
|
||||
j==-1
|
||||
OD
|
||||
a(j+1)=value
|
||||
OD
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
DEFINE COUNT="7"
|
||||
PTR ARRAY arr(COUNT)
|
||||
|
||||
arr(0)="violet" arr(1)="red"
|
||||
arr(2)="green" arr(3)="indigo"
|
||||
arr(4)="blue" arr(5)="yellow"
|
||||
arr(6)="orange"
|
||||
|
||||
Print("Shuffled array: ")
|
||||
PrintArray(arr,COUNT) PutE()
|
||||
|
||||
InteractiveInsertionSort(arr,COUNT)
|
||||
PutE() Print("Sorted array: ")
|
||||
PrintArray(arr,COUNT)
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue