tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,34 @@
|
|||
prn$ = "3 4 2 * 1 5 - 2 3 ^ ^ / + "
|
||||
|
||||
j = 0
|
||||
while word$(prn$,i + 1," ") <> ""
|
||||
i = i + 1
|
||||
n$ = word$(prn$,i," ")
|
||||
if n$ < "0" or n$ > "9" then
|
||||
num1 = val(word$(stack$,s," "))
|
||||
num2 = val(word$(stack$,s-1," "))
|
||||
n = op(n$,num2,num1)
|
||||
s = s - 1
|
||||
stack$ = stk$(stack$,s -1,str$(n))
|
||||
print "Push Opr ";n$;" to stack: ";stack$
|
||||
else
|
||||
s = s + 1
|
||||
stack$ = stack$ + n$ + " "
|
||||
print "Push Num ";n$;" to stack: ";stack$
|
||||
end if
|
||||
wend
|
||||
|
||||
function stk$(stack$,s,a$)
|
||||
for i = 1 to s
|
||||
stk$ = stk$ + word$(stack$,i," ") + " "
|
||||
next i
|
||||
stk$ = stk$ + a$ + " "
|
||||
end function
|
||||
|
||||
FUNCTION op(op$,a,b)
|
||||
if op$ = "*" then op = a * b
|
||||
if op$ = "/" then op = a / b
|
||||
if op$ = "^" then op = a ^ b
|
||||
if op$ = "+" then op = a + b
|
||||
if op$ = "-" then op = a - b
|
||||
end function
|
||||
Loading…
Add table
Add a link
Reference in a new issue