频道分类

delphi 二十四点

作者:admin 来源: 日期:2021/8/22 11:13:50 人气: 标签:

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, uTF;

type
  TForm1 = class(TForm)
    memMsg: TMemo;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
    FTFList: TTFList;
    procedure DispMsg(AMsg: string);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

{ TForm1 }
uses
  Math;

procedure TForm1.Button1Click(Sender: TObject);
var
  LTF: TTF;
  N1, n2, n3, n4: integer;

  sNums: string;
  smsg: string;
begin

  FTFList.ClearAndFreeAllItems;

  Randomize;

  N1 := RandomRange(1, 11);
  n2 := RandomRange(1, 11);
  n3 := RandomRange(1, 11);
  n4 := RandomRange(1, 11);

  LTF := FTFList.AddNewOne;
  LTF.Value := N1;
  LTF := FTFList.AddNewOne;
  LTF.Value := n2;
  LTF := FTFList.AddNewOne;
  LTF.Value := n3;
  LTF := FTFList.AddNewOne;
  LTF.Value := n4;

  sNums := N1.ToString + ',' + n2.ToString + ',' + n3.ToString + ',' + n4.ToString;
  DispMsg('数字:' + sNums);
  LTF := nil;
  smsg := DoCount(FTFList);
  DispMsg(smsg + '=24');
  DispMsg('---------------------------');

end;

procedure TForm1.DispMsg(AMsg: string);
begin
  memMsg.Lines.Add(AMsg);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  FTFList := TTFList.Create;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FTFList.Free;
end;

end.

上一篇:delphi 生成当月月份列表下一篇:没有资料