Delphi:一个新算法的表达式求值的函数
来源:优易学  2011-9-18 16:03:24   【优易学:中国教育考试门户网】   资料下载   IT书店

  interface
  uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,StrUtils, Spin;
  type
  TForm1 = class(TForm)
  Edit1: TEdit;
  Edit2: TEdit;
  Button1: TButton;
  Button2: TButton;
  SpinEdit1: TSpinEdit;
  procedure Button1Click(Sender: TObject);
  procedure Button2Click(Sender: TObject);
  private
  { Private declarations }
  public
  { Public declarations }
  end;
  var
  Form1: TForm1;
  implementation
  {$R *.dfm}
  function nospace(s:string):string;
  begin
  result:= stringreplace(s,\' \',\'\',[rfReplaceAll]);
  end;
  function is123(c:char):boolean;
  begin
  if c in [\'0\'..\'9\',\'.\']
  then result:=true
  else result:=false;
  end;
  function isminus(s:string;i:integer):boolean ;
  var
  t:integer;
  begin
  for t:=i-1 downto 1 do
  begin
  if s[t]=\')\' then
  begin
  result:=false;
  break;
  end;
  if (s[t]=\'(\') and (s[t+1]=\'-\') then
  begin
  result:=true;
  break;
  end;
  if (not is123(s[t])) and ( not ((s[t]=\'-\') and(s[t-1]=\'(\'))) then
  begin
  result:=false;
  break;
  end;
  end;
  end;
  function firstJ(s:string):integer ;
  var
  i,L:integer;
  begin
  result:=0;
  L:=length(s);
  for i:=1 to L do
  begin
  if (s[i]=\')\') and (not isminus(s,i)) then
  begin
  result:=i;
  break;
  end;
  end;
  end;

[1] [2] [3] [4] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训