打印本文 打印本文 关闭窗口 关闭窗口
一个新算法的表达式求值的函数
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1688  更新时间:2009/4/23 18:35:48  文章录入:mintao  责任编辑:mintao
=nospace(s);
s0:=s;
L:=length(s);
if (s[1]<>''''('''') or (s[L]<>'''')'''')  then
s:=''''(''''+s+'''')'''';
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.

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口