一个新算法的表达式求值的函数[3]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 e271828 的 blog

if (s[1]='(') and (s[l]=')') and((s[2]='-')  or (isminus(s,l)))  then
s:='('+s+')';
l:=length(s);
j:=firstj(s);
c:=firstc(s,j);
if (j<l) and (c>1) and (j>c) then
begin
substr:=copy(s,c+1,j-c-1);
file://le:=leftstr(s,c-1);
file://ri:= rightstr(s,l-j);
le:=leftstr(s,c-1);
le:=rightstr(le,length(le)-1);
ri:= rightstr(s,l-j);
ri:=leftstr(ri,length(ri)-1);
file://showmessage(substr);
al:=alltoone(substr);
file://showmessage(le+al+ri);
result:=myexpress(le+al+ri);
end
else
result:=alltoone(s0);

end;
procedure tform1.button1click(sender: tobject);
begin
edit2.text:=myexpress(edit1.text);
end;

end.

本文关键:一个表达式求值的函数,pascal,lijunyu
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top