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

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

?? calcexpress.pas

?? CalcExpress is an interpreter for quick and easy evaluation of mathematical expressions. It is a sm
?? 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一区二区三区免费野_久草精品视频
欧美一区二区三区啪啪| 91偷拍与自偷拍精品| 亚洲一区在线电影| 亚洲主播在线观看| 日韩精品一级中文字幕精品视频免费观看 | 亚洲欧洲无码一区二区三区| 中文成人综合网| 一区二区三区中文字幕在线观看| 亚洲激情自拍视频| 国产中文字幕一区| 高清不卡一区二区| 欧美日韩一级二级| 国产视频一区二区在线观看| 亚洲欧美日韩国产成人精品影院| 丝袜美腿成人在线| 99久久免费视频.com| 91.com在线观看| 综合激情成人伊人| 99精品在线观看视频| 91精品国产高清一区二区三区| 久久久精品影视| 亚洲自拍偷拍欧美| 色琪琪一区二区三区亚洲区| 久久亚洲二区三区| 婷婷综合在线观看| 99亚偷拍自图区亚洲| 久久久五月婷婷| 美女视频免费一区| 欧美日韩夫妻久久| 亚洲自拍都市欧美小说| 91亚洲精品久久久蜜桃| 国产精品久久久久久久久晋中| 麻豆精品视频在线观看免费 | 久久男人中文字幕资源站| 免费三级欧美电影| 欧美日韩高清一区二区不卡| 亚洲久草在线视频| 日本高清成人免费播放| 亚洲另类春色国产| 日本大香伊一区二区三区| 中文字幕亚洲一区二区va在线| 国产在线观看一区二区| 精品黑人一区二区三区久久| 九九视频精品免费| 久久精品亚洲国产奇米99| 国产成人精品网址| 亚洲天堂免费看| 91国模大尺度私拍在线视频| 午夜精品国产更新| 日韩视频一区二区三区在线播放| 另类小说欧美激情| 日本一区二区久久| 欧美日本乱大交xxxxx| 激情欧美一区二区| 亚洲欧美日韩一区二区三区在线观看| 欧美色综合网站| 九一久久久久久| 一区二区三区成人| 久久久高清一区二区三区| 91麻豆6部合集magnet| 美女网站一区二区| 亚洲精品水蜜桃| 久久久久久97三级| 日韩欧美亚洲另类制服综合在线| 成人av免费在线| 国产又黄又大久久| 日韩国产高清在线| 一二三区精品视频| 国产精品久久久久久亚洲伦| 欧美日韩国产a| 色婷婷综合久久久| av色综合久久天堂av综合| 久久国产免费看| 性做久久久久久免费观看欧美| 18涩涩午夜精品.www| 国产视频亚洲色图| 久久五月婷婷丁香社区| 日韩欧美在线1卡| 制服丝袜一区二区三区| 欧美手机在线视频| 欧美性猛交xxxx乱大交退制版| eeuss鲁片一区二区三区在线观看| 精品在线观看视频| 久久精品国产久精国产| 免费人成黄页网站在线一区二区| 亚州成人在线电影| 免费观看久久久4p| 国产一区二区女| 粉嫩绯色av一区二区在线观看| 国产在线一区观看| 成人av网在线| 欧美最猛黑人xxxxx猛交| 欧美综合久久久| 日韩午夜激情视频| 日韩在线卡一卡二| 国产伦理精品不卡| 91色综合久久久久婷婷| 欧美在线你懂得| 欧美本精品男人aⅴ天堂| 国产欧美日韩中文久久| 一区二区三区欧美日| 理论片日本一区| 99视频一区二区| 精品久久久久久综合日本欧美| 精品成人在线观看| 综合久久给合久久狠狠狠97色| 日韩**一区毛片| 波多野结衣中文字幕一区| 91精品在线观看入口| 婷婷丁香久久五月婷婷| 成人97人人超碰人人99| 欧美一区二区三区四区在线观看| 国产精品青草综合久久久久99| 无码av中文一区二区三区桃花岛| 99久久精品情趣| 国产拍欧美日韩视频二区| 日本va欧美va欧美va精品| 91高清视频在线| 亚洲三级在线看| 成人午夜视频网站| 中文字幕精品在线不卡| 国内精品自线一区二区三区视频| 欧美日韩午夜在线视频| 亚洲欧美日韩小说| 99re在线精品| 亚洲精品成a人| 欧美在线free| 日产国产欧美视频一区精品| 欧美日韩久久不卡| 日韩精品一级二级| 欧美刺激脚交jootjob| 日韩电影一区二区三区| 欧美一级高清片| 国内精品视频666| 精品成人一区二区三区四区| 国产乱码精品一区二区三区忘忧草| 91精品婷婷国产综合久久性色| 看电影不卡的网站| 国产亚洲一区二区三区在线观看 | 色综合久久久网| 亚洲国产精品久久久久秋霞影院| 欧美性大战xxxxx久久久| 五月天久久比比资源色| 精品国产自在久精品国产| 国产成人激情av| 亚洲一区二区精品视频| 337p粉嫩大胆色噜噜噜噜亚洲 | 69堂国产成人免费视频| 国产99久久久久久免费看农村| 亚洲精品成人a在线观看| 欧美一区二区三区免费在线看| 国内外成人在线| 性久久久久久久久| 中文字幕欧美三区| 欧美二区乱c少妇| 一本一道综合狠狠老| 捆绑调教一区二区三区| 亚洲免费观看高清完整| 久久一日本道色综合| 91精品综合久久久久久| 色婷婷av一区二区三区软件| 国产剧情一区二区三区| 日韩电影在线免费| 午夜精品久久久久久久99樱桃| 国产日韩欧美高清| 久久久久久久久久久久久久久99| 91精品国产综合久久精品app | 久久综合资源网| 精品国产在天天线2019| 欧美一二三区在线| 日韩午夜中文字幕| 日韩三级.com| 2023国产精品视频| 久久久精品综合| 久久久久99精品一区| 中文字幕第一区| 国产精品色呦呦| 国产精品久久久久一区二区三区 | 狂野欧美性猛交blacked| 久久国产精品72免费观看| 久久福利视频一区二区| 国产精品综合二区| 成人av在线播放网址| 色综合久久综合网97色综合| 欧美日韩在线亚洲一区蜜芽| 日本高清不卡视频| 91精品婷婷国产综合久久性色| 制服丝袜中文字幕一区| 欧美成人精品福利| 国产精品久久福利| 亚洲午夜三级在线| 风间由美一区二区av101| 一本久久精品一区二区| 666欧美在线视频| 国产日韩欧美不卡在线| 日韩中文字幕1| 高清在线不卡av| 欧美日韩在线免费视频| 精品美女在线播放| 国产精品成人在线观看|