亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? calcexpress.pas

?? delphi 計算用第三方 控件
?? PAS
字號:
//==============================================================================
// Product name: CalcExpress
// Copyright 2000-2002 AidAim Software.
// Description:
//  CalcExpress is an interpreter for quick and easy
//  evaluation of mathematical expressions.
//  It is a smart tool easy in use.
//  Supports 5 operators, parenthesis, 18 mathematical functions and
//  user-defined variables.
// Date: 06/14/2001
//==============================================================================
unit CalcExpress;

interface

{DEFINE aaCLX} // set $ after { to get CLX version

uses
  SysUtils, Classes, Math,
{$IFDEF aaCLX}
  QGraphics, QControls, QForms, QDialogs, QExtCtrls;
{$ELSE}
  Windows, Messages, Graphics, Controls, Forms, Dialogs, ExtCtrls;
{$ENDIF}

type

  TTree = record
    num: integer;
    con: string;
    l, r: pointer;
  end;

  PTree = ^TTree;

  TCalcExpress = class(TComponent)
  private
    Err: boolean;
    Bc: integer;
    PrevLex, Curlex: integer;
    Pos: integer;
    FFormula: string;
    Tree: pointer;
    FVariables: TStrings;
    FDefaultNames: boolean;
    procedure init(s: string);
    function gettree(s: string): pointer;
    function deltree(t: PTree): pointer;
    procedure Error(s: string);
    procedure SetVariables(Value: TStrings);
  public
    constructor Create(o: TComponent); override;
    destructor Destroy; override;
    function calc(args: array of extended): extended;
  published
    property Formula: string read FFormula write init;
    property Variables: TStrings read FVariables write SetVariables;

  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TCalcExpress]);
end;

//*********************************************************************
function TCalcExpress.calc(args: array of extended): extended;
  function c(t: PTREE): extended;
  var 
    r: extended;
  begin
    c := 0;
    case t^.num of
      3: c := c(t^.l) + c(t^.r);
      4: c := c(t^.l) - c(t^.r);
      5: c := c(t^.l) * c(t^.r);
      6: c := c(t^.l) / c(t^.r);
      7: c := strtofloat(t^.con);
      8: c := args[StrToInt(t^.con)];
      9: c := -c(t^.l);
      10: c := cos(c(t^.l));
      11: c := sin(c(t^.l));
      12: c := tan(c(t^.l));
      13: c := 1 / tan(c(t^.l));
      14: c := abs(c(t^.l));
      15: 
      begin
        r := c(t^.l);
        if r < 0 then c := -1 
        else if r > 0 then c := 1 
        else 
          c := 0;
      end;
      16: c := sqrt(c(t^.l));
      17: c := ln(c(t^.l));
      18: c := exp(c(t^.l));
      19: c := arcsin(c(t^.l));
      20: c := arccos(c(t^.l));
      21: c := arctan(c(t^.l));
      22: c := pi / 2 - arctan(c(t^.l));
      23: 
      begin
        r := c(t^.l);
        c := (exp(r) - exp(-r)) / 2;
      end;
      24: 
      begin
        r := c(t^.l);
        c := (exp(r) + exp(-r)) / 2;
      end;
      25: 
      begin
        r := c(t^.l);
        c := (exp(r) - exp(-r)) / (exp(r) + exp(-r));
      end;
      26: 
      begin
        r := c(t^.l);
        c := (exp(r) + exp(-r)) / (exp(r) - exp(-r));
      end;
      27: 
      begin
        r := c(t^.l);
        if r >= 0 then c := 1 
        else 
          c := 0;
      end;
      31: c := power(c(t^.l), c(t^.r));
    end;
  end;
begin
  calc := c(tree);
end;

procedure TCalcExpress.Error(s: string);
begin
  Err := True;
  raise Exception.Create(s);
end;
//*********************************************************************
constructor TCalcExpress.Create(o: TComponent);
begin
  inherited;
  Tree := nil;
  Formula := '0';
  FDefaultNames := False;
  FVariables := TStringList.Create;
end;
//*********************************************************************
destructor TCalcExpress.Destroy;
begin
  DelTree(Tree);
  FVariables.Free;
  inherited;
end;

//***************************************************************

function TCalcExpress.GetTree(s: string): pointer;
  //Get number from string
  function getnumber(s: string): string;
  begin
    Result := '';
    try
      //Begin
      while (pos <= length(s)) and (s[pos] in ['0'..'9']) do
      begin
        Result := Result + s[pos];
        inc(pos);
      end;
      if pos > length(s) then exit;
      if s[pos] = DecimalSeparator then
      begin
        //Fraction part
        Result := Result + DecimalSeparator;
        inc(pos);
        if (pos > length(s)) or not (s[pos] in ['0'..'9']) then Error('Wrong number.');
        while (pos <= length(s)) and
          (s[pos] in ['0'..'9']) do
        begin
          Result := Result + s[pos];
          inc(pos);
        end;
      end;
      if pos > length(s) then exit;
      //Power
      if (s[pos] <> 'e') and (s[pos] <> 'E') then exit;
      Result := Result + s[pos];
      inc(pos);
      if pos > length(s) then Error('Wrong number.');
      if s[pos] in ['-', '+'] then
      begin
        Result := Result + s[pos];
        inc(pos);
      end;
      if (pos > length(s)) or not (s[pos] in ['0'..'9']) then Error('Wrong number.');
      while (pos <= length(s)) and
        (s[pos] in ['0'..'9']) do
      begin
        Result := Result + s[pos];
        inc(pos);
      end;
    except
    end;
  end;
  //Read lexem from string
  procedure getlex(s: string; var num: integer; var con: string);
  begin
    con := '';
    //skip spaces
    while (pos <= length(s)) and (s[pos] = ' ') do inc(pos);
    if pos > length(s) then 
    begin 
      num := 0;  
      exit; 
    end;

    case s[pos] of
      '(': num := 1;
      ')': num := 2;
      '+': num := 3;
      '-': 
      begin
        num := 4;
        if (pos < length(s)) and (s[pos + 1] in ['1'..'9', '0']) and (curlex in [0,1]) then
        begin
          inc(pos);
          con := '-' + getnumber(s);
          dec(pos);
          num := 7;
        end;
      end;
      '*': num := 5;
      '/': num := 6;
      '^': num := 31;
      'a'..'z', 'A'..'Z', '_':
      begin
        while (pos <= length(s)) and
          (s[pos] in ['a'..'z', 'A'..'Z', '_', '1'..'9', '0']) do
        begin
          con := con + s[pos];
          inc(pos);
        end;
        dec(pos);
        num := 8;
        if con = 'cos' then num := 10;
        if con = 'sin' then num := 11;
        if con = 'tg' then num := 12;
        if con = 'ctg' then num := 13;
        if con = 'abs' then num := 14;
        if (con = 'sgn') or (con = 'sign') then num := 15;
        if con = 'sqrt' then num := 16;
        if con = 'ln' then num := 17;
        if con = 'exp' then num := 18;
        if con = 'arcsin' then num := 19;
        if con = 'arccos' then num := 20;
        if (con = 'arctg') or (con = 'arctan') then num := 21;
        if con = 'arcctg' then num := 22;
        if (con = 'sh') or (con = 'sinh') then num := 23;
        if (con = 'ch') or (con = 'cosh') then num := 24;
        if (con = 'th') or (con = 'tanh') then num := 25;
        if (con = 'cth') or (con = 'coth') then num := 26;
        if (con = 'heaviside') or (con = 'h') then num := 27;
        if num = 8 then  con := IntToStr(FVariables.IndexOf(con));
      end;
      '1'..'9', '0':
      begin
        con := getnumber(s);
        dec(pos);
        num := 7;
      end;
    end;
    inc(pos);
    PrevLex := CurLex;
    CurLex := num;
  end;

  //****************************************************************
var 
  neg: boolean;
  l, r, res: PTree;
  n, op: integer;
  c: string;
  //****************************************************************
  function newnode: PTree;
  begin
    Result := allocmem(sizeof(TTree));
    Result^.l := nil;
    Result^.r := nil;
  end;

  function getsingleop: pointer;
  var 
    op, bracket: integer;
    opc: string;
    l, r, res: PTree;
  begin
    l := nil;
    try
      if n = 1 then 
      begin 
        inc(bc); 
        l := gettree(s); 
      end
      else
      begin
        // First operand
        if not (n in [7,8,10..30]) then Error('');
        op := n;
        opc := c;
        if n in [7,8] then
        begin
          // Number or variable
          l := newnode; 
          l^.num := op; 
          l^.con := opc;
        end 
        else
        begin
          //Function
          getlex(s, n, c);
          if n <> 1 then Error('');
          inc(bc);
          l := newnode;
          l^.l := gettree(s); 
          l^.num := op; 
          l^.con := opc;
        end;
      end;
      //Operation symbol
      getlex(s, n, c);
      //Power symbol
      while n = 31 do
        begin
          getlex(s, n, c);
        bracket := 0;
        if n = 1 then  
        begin   
          bracket := 1;   
          getlex(s, n, c);   
        end;
        if (n <> 7) and (n <> 8) then Error('');
        r := newnode; 
        r^.num := n; 
        r^.con := c;
        res := newnode; 
        res^.l := l; 
        res^.r := r; 
        res^.num := 31; 
        l := res;
        if bracket = 1 then
        begin
          getlex(s, n, c);
          if n <> 2 then Error('');
        end;
        getlex(s, n, c);
      end;
      Result := l;
    except
      DelTree(l);
      Result := nil;
    end;
  end;
  //****************************************************************
  function getop: pointer;
  var 
    op: integer;
    l, r, res: PTree;
  begin
    neg := False;
    getlex(s, n, c);
    // Unary - or +
    if prevlex in [0,1] then
    begin
      if n = 4 then  
      begin  
        neg := True; 
        getlex(s, n, c);  
      end;
      if n = 3 then getlex(s, n, c);
    end;
    l := getsingleop;
    // 2nd operand **************
    while n in [5,6] do
    begin
      op := n;
      getlex(s, n, c);
      r := getsingleop;
      res := allocmem(sizeof(TTree));
      res^.l := l; 
      res^.r := r; 
      res^.num := op;
      l := res;
    end;
    // Unary minus
    if neg then
    begin
      res := allocmem(sizeof(TTree));
      res^.l := l; 
      res^.r := nil; 
      res^.num := 9;
      l := res;
    end;
    Result := l;
  end;

  //****************************************************************
begin
  l := nil;
  try
    l := getop;
    while True do
    begin
      if n in [0,2] then
      begin
        if n = 2 then dec(bc);
        Result := l; 
        exit;
      end;
      if not (n in [3,4]) then Error('');
      op := n;
      r := getop;
      res := allocmem(sizeof(TTree));
      res^.l := l; 
      res^.r := r; 
      res^.num := op;
      l := res;
    end;
    Result := l;
  except
    DelTree(l);
    Result := nil;
  end;
end;

//******************************************************************

procedure TCalcExpress.init(s: string);
begin
  deltree(tree);
  Err := False;
  FFormula := LowerCase(s);
  Prevlex := 0;  
  Curlex := 0;  
  Pos := 1;  
  bc := 0;
  Tree := GetTree(Lowercase(s));
  if (bc <> 0) or Err then
  begin
    ShowMessage('Error in formula.');
    Tree := DelTree(Tree);
  end;
end;

//Tree deletion

function TCalcExpress.deltree(t: PTree): pointer;
begin
  Result := nil;
  if t = nil then exit;
  if t^.l <> nil then Deltree(t^.l);
  if t^.r <> nil then Deltree(t^.r);
  freemem(t);
end;

//****************************************************************
procedure TCalcExpress.SetVariables(Value: TStrings);
begin
  FVariables.Clear;
  FVariables.Assign(Value);
  Init(Formula);
end;


end.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费成人在线网站| 奇米四色…亚洲| 成人午夜av在线| 精品国产乱码久久久久久蜜臀| 亚洲精品日韩专区silk| 日韩电影在线观看电影| 欧美精品自拍偷拍| 三级久久三级久久久| 欧美午夜精品一区| 亚洲国产精品自拍| 51午夜精品国产| 视频一区在线视频| 日韩欧美在线影院| 韩国精品久久久| 中文字幕国产一区二区| 美女看a上一区| 精品国产三级电影在线观看| 天堂精品中文字幕在线| 日韩视频在线观看一区二区| 青青草97国产精品免费观看 | 国产精品一线二线三线| 91女人视频在线观看| 亚洲激情在线播放| 4438成人网| 日韩精品成人一区二区在线| 91精品国产综合久久精品图片| 日韩一区在线看| 欧美色倩网站大全免费| 亚洲国产你懂的| 91在线你懂得| 亚洲chinese男男1069| 欧美成人精品二区三区99精品| 蜜臀久久99精品久久久久宅男| 欧美精品在欧美一区二区少妇| 久久99热99| 中文在线资源观看网站视频免费不卡| av动漫一区二区| 久久精品一区二区三区四区| 97久久久精品综合88久久| 亚洲第一会所有码转帖| 欧美日韩国产高清一区二区 | 国产午夜精品理论片a级大结局| 成人丝袜高跟foot| 午夜免费欧美电影| 国产亲近乱来精品视频| 欧美日韩在线三区| 风间由美一区二区av101| 亚洲欧洲日本在线| 色一情一伦一子一伦一区| 日本欧美在线观看| 国产精品乱子久久久久| 欧美日精品一区视频| 精品一区二区三区免费观看| 国产精品免费视频网站| 日韩一区二区在线看片| 色婷婷av一区二区三区大白胸| 久久精品理论片| 最好看的中文字幕久久| 欧美一区二区性放荡片| 国产中文字幕精品| 亚洲v日本v欧美v久久精品| 久久久精品中文字幕麻豆发布| 国产 日韩 欧美大片| 亚洲444eee在线观看| 亚洲欧洲www| 国产日产欧美精品一区二区三区| 在线观看欧美日本| 成人av动漫在线| 亚洲国产色一区| 精品国产一二三| 欧美一级欧美三级| 欧美三区在线视频| 91免费小视频| 9i在线看片成人免费| 国产精品一二三四五| 亚洲线精品一区二区三区| 亚洲视频综合在线| 日韩精品在线网站| 欧美日韩成人在线| 色激情天天射综合网| 国内精品第一页| 老司机精品视频一区二区三区| 午夜精品一区二区三区免费视频 | 亚洲男人的天堂一区二区| 欧美精品一区二区三区在线| 欧美日韩日日骚| 欧美日韩精品一二三区| 欧美日韩在线电影| 欧洲视频一区二区| 91网站最新网址| 色综合久久中文综合久久牛| av午夜精品一区二区三区| 成人激情小说网站| 99久久综合色| 91亚洲精华国产精华精华液| 成人黄色a**站在线观看| 成人精品免费网站| 成人av午夜电影| av午夜一区麻豆| 色狠狠一区二区三区香蕉| 日本精品一区二区三区四区的功能| 97久久精品人人做人人爽50路| 99久久er热在这里只有精品15| 在线精品视频小说1| 日韩欧美在线1卡| 国产精品久久久久三级| 一区二区免费看| 精品中文字幕一区二区小辣椒| 成人av免费在线观看| 欧美日韩精品电影| 国产拍揄自揄精品视频麻豆| 一区二区不卡在线播放 | 欧美日韩一级二级| 国产亚洲成aⅴ人片在线观看| 亚洲欧美精品午睡沙发| 极品美女销魂一区二区三区免费 | 国产黄色精品视频| 精品视频123区在线观看| www国产成人免费观看视频 深夜成人网| 国产精品不卡在线| 美女在线视频一区| 91国产免费看| 国产欧美日韩精品在线| 天堂va蜜桃一区二区三区| 不卡视频一二三四| 日韩精品中文字幕一区| 亚洲精品久久久久久国产精华液| 韩国精品一区二区| 精久久久久久久久久久| 成人一区在线观看| 日韩视频123| **性色生活片久久毛片| 精品一区免费av| 欧美日韩在线一区二区| 色综合 综合色| 精品成人佐山爱一区二区| 亚洲成人资源网| 99久久99久久精品国产片果冻 | 日本一区二区三区四区| 国产综合色视频| 欧美精彩视频一区二区三区| 国产精品一区二区黑丝| 国产亚洲午夜高清国产拍精品| 国产精品一区二区你懂的| 久久久一区二区| www.欧美亚洲| 亚洲一区二区三区爽爽爽爽爽 | 国内精品久久久久影院薰衣草| 久久综合给合久久狠狠狠97色69| 国产麻豆日韩欧美久久| 中文字幕 久热精品 视频在线| 99视频一区二区三区| 亚洲精品网站在线观看| 欧美三级视频在线播放| 日本aⅴ免费视频一区二区三区| 欧美va在线播放| 床上的激情91.| 亚洲一线二线三线久久久| 欧美精品tushy高清| 韩国午夜理伦三级不卡影院| 国产精品伦一区二区三级视频| 色综合天天在线| 青青草精品视频| 欧美国产国产综合| 欧美天堂一区二区三区| 久久福利资源站| 亚洲四区在线观看| 日韩午夜小视频| av一区二区不卡| 男女性色大片免费观看一区二区| 国产欧美视频在线观看| 日本高清成人免费播放| 久久疯狂做爰流白浆xx| 亚洲欧洲99久久| 日韩午夜在线影院| 91尤物视频在线观看| 老司机免费视频一区二区三区| 国产精品卡一卡二卡三| 91精品婷婷国产综合久久性色| 懂色av中文字幕一区二区三区| 亚洲一二三四久久| 久久久另类综合| 欧美日韩免费在线视频| 成人性生交大片免费看视频在线 | 国产精品美女久久久久aⅴ国产馆| 在线亚洲一区观看| 国产一区二区导航在线播放| 亚洲蜜臀av乱码久久精品| 精品成人在线观看| 欧美日韩国产综合一区二区三区| 国产成人精品免费视频网站| 亚洲午夜一区二区| 中文字幕av在线一区二区三区| 欧美日韩国产区一| 91丨九色丨蝌蚪丨老版| 国产一区二区三区精品欧美日韩一区二区三区 | 一区二区三区在线免费视频| 久久亚洲二区三区| 日韩一区二区电影| 欧美亚洲愉拍一区二区|