Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
41
Task/Queue-Usage/Yabasic/queue-usage.basic
Normal file
41
Task/Queue-Usage/Yabasic/queue-usage.basic
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
sub push(x$)
|
||||
queue$ = queue$ + x$ + "#"
|
||||
end sub
|
||||
|
||||
sub pop$()
|
||||
local i, r$
|
||||
|
||||
if queue$ <> "" then
|
||||
i = instr(queue$, "#")
|
||||
if i then
|
||||
r$ = left$(queue$, i-1)
|
||||
stack$ = right$(queue$, len(queue$) - i)
|
||||
else
|
||||
r$ = queue$
|
||||
queue$ = ""
|
||||
end if
|
||||
return r$
|
||||
else
|
||||
print "--Queue is empty--"
|
||||
end if
|
||||
end sub
|
||||
|
||||
sub empty()
|
||||
return queue$ = ""
|
||||
end sub
|
||||
|
||||
// ======== test ========
|
||||
|
||||
for n = 3 to 5
|
||||
print "Push ", n : push(str$(n))
|
||||
next
|
||||
|
||||
print "Pop ", pop$()
|
||||
|
||||
print "Push ", 6 : push(str$(6))
|
||||
|
||||
while(not empty())
|
||||
print "Pop ", pop$()
|
||||
wend
|
||||
|
||||
print "Pop ", pop$()
|
||||
Loading…
Add table
Add a link
Reference in a new issue