Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
31
Task/Stack/BBC-BASIC/stack.basic
Normal file
31
Task/Stack/BBC-BASIC/stack.basic
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
STACKSIZE = 1000
|
||||
|
||||
FOR n = 3 TO 5
|
||||
PRINT "Push ";n : PROCpush(n)
|
||||
NEXT
|
||||
PRINT "Pop " ; FNpop
|
||||
PRINT "Push 6" : PROCpush(6)
|
||||
REPEAT
|
||||
PRINT "Pop " ; FNpop
|
||||
UNTIL FNisempty
|
||||
PRINT "Pop " ; FNpop
|
||||
END
|
||||
|
||||
DEF PROCpush(n) : LOCAL f%
|
||||
DEF FNpop : LOCAL f% : f% = 1
|
||||
DEF FNisempty : LOCAL f% : f% = 2
|
||||
PRIVATE stack(), sptr%
|
||||
DIM stack(STACKSIZE-1)
|
||||
CASE f% OF
|
||||
WHEN 0:
|
||||
IF sptr% = DIM(stack(),1) ERROR 100, "Error: stack overflowed"
|
||||
stack(sptr%) = n
|
||||
sptr% += 1
|
||||
WHEN 1:
|
||||
IF sptr% = 0 ERROR 101, "Error: stack empty"
|
||||
sptr% -= 1
|
||||
= stack(sptr%)
|
||||
WHEN 2:
|
||||
= (sptr% = 0)
|
||||
ENDCASE
|
||||
ENDPROC
|
||||
Loading…
Add table
Add a link
Reference in a new issue