Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
40
Task/Stack/Yabasic/stack.basic
Normal file
40
Task/Stack/Yabasic/stack.basic
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
limit = 1000
|
||||
dim stack(limit)
|
||||
|
||||
top = 0
|
||||
|
||||
sub push(n)
|
||||
if top < limit then
|
||||
top = top + 1 : stack(top) = n
|
||||
else
|
||||
print "stack full - ";
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub pop()
|
||||
if top then
|
||||
top = top - 1 : return stack(top + 1)
|
||||
else
|
||||
print "stack empty - ";
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub empty()
|
||||
return not top
|
||||
end sub
|
||||
|
||||
// ======== test ========
|
||||
|
||||
for n = 3 to 5
|
||||
print "Push ", n : push(n)
|
||||
next
|
||||
|
||||
print "Pop ", pop()
|
||||
|
||||
print "Push ", 6 : push(6)
|
||||
|
||||
while(not empty())
|
||||
print "Pop ", pop()
|
||||
wend
|
||||
|
||||
print "Pop ", pop()
|
||||
Loading…
Add table
Add a link
Reference in a new issue