zoukankan      html  css  js  c++  java
  • Handbook之012:函数类别构型

    定义函数构型,然后在再调用函数

    image

    代码如下:

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows,
      Winapi.Messages,
      System.SysUtils,
      System.Variants,
      System.Classes,
      Vcl.Graphics,
      Vcl.Controls,
      Vcl.Forms,
      Vcl.Dialogs,
      Vcl.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.dfm}
    uses
      System.Diagnostics,
      System.Math;
    
    //函数定义
    procedure ShowOnMemo(ACount: Integer);
    var
      m_Watch: TStopwatch;
      I, J: Integer;
    begin
      J := 0;
      m_Watch := TStopwatch.StartNew;
      for I := 0 to ACount do
      begin
        J := Max(I, J);
      end;
      m_Watch.Stop;
      Form1.Memo1.Lines.Add('循环总耗时: ' + m_Watch.ElapsedMilliseconds.ToString);
    end;
    //定义函数构型
    
    type
      TIntProc = procedure(Num: Integer);
    
    //计时
    procedure TForm1.Button1Click(Sender: TObject);
    var
      m_Pro: TIntProc;
      m_Count: Integer;
    begin
      m_Pro := ShowOnMemo;
      m_Count := 2000000;
      m_Pro(m_Count);
    end;
    
    end.
  • 相关阅读:
    CentOS 5.5和5.6 安装后的网络配置
    CentOS 5.5 系统安全配置
    printk: messages suppressed
    “找不到出路的”vb6.0
    用户控件的烦扰
    rman恢复
    oracle数据字典
    oracle自关联表的子删父变功能实现
    oracle自治事务
    oracle表空间更名
  • 原文地址:https://www.cnblogs.com/GodPan/p/4908121.html
Copyright © 2011-2022 走看看