| |
|
|
| Eine in einem String abgelegte Gleichung ausrechnen.<hr> KompilierenMarkierenSeparierenprint "iF-Calcer :)";chr$(10)
declare os$,s$,stack&,num&,oop$,op$,tmp$
s$="20*300-1+1+4:2:2*10="
os$=s$
stack&=0
oop$=""
op$=""
while len(s$)
tmp$=""
while (ord(mid$(s$,1,1)) > 47) and (ord(mid$(s$,1,1)) <58) and len(s$)
tmp$=tmp$+mid$(s$,1,1)
s$=del$(s$,1,1)
wend
oop$=op$
op$=mid$(s$,1,1)
s$=del$(s$,1,1)
ifnot len(oop$)
stack&=stack&+val(tmp$)
elseif oop$="+"
stack&=stack&+val(tmp$)
elseif oop$="-"
stack&=stack&-val(tmp$)
elseif (oop$="/") or (oop$=":")
stack&=stack& / val(tmp$)
elseif (oop$="*") or (oop$="x")
stack&=stack& * val(tmp$)
endif
wend
print os$;stack&
waitkey
end
iF |
|
|
| |
|
|