this one must looks better
as img
as image ...
Code: (Select All)
'create stack using array (...of integers) o2 by Aurel 13.1.2025
string crlf = chr(13) + chr(10), stbuff
int stack[16] ,size = 16
int top = 0
! push(int i)
! pop() as int
! peek() as int
sub push(int a)
if top = size - 1
print "Stack is Overflow!" : goto exitProgram
else
top = top + 1 ' increment stack index
stack[top] = a ' enter value
end if
end sub
sub pop()
if top = 0
print "Stack is Underflow!" : goto exitProgram
else
stack[top] = 0 ' remove curent value
top = top - 1 ' decrement stack index
end if
end sub
sub printStack()
int i
for i = 1 to top
stbuff = stbuff + str(i) + " : " + str(stack[i]) + crlf
next i
'show stack
print stbuff
end sub
'push some values on the stack
int v=1,x=10
while v < 11
push(x)
x = x + 10
v=v+1
wend
'test 1......
printStack()
exitProgram:
print "EXIT..."
as img
as image ...
micro(A)developer
http://basic4us.epizy.com/forum/index.php
http://basic4us.epizy.com/forum/index.php