⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 d5.~pas

📁 delphi编写的彩票分析程序
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
unit d5;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ComCtrls, Grids, DBGrids, ExtCtrls, DB, StdCtrls, Buttons,
  DBTables,StrUtils;

type
  TForm1 = class(TForm)
    DataSource1: TDataSource;
    Panel1: TPanel;
    Panel2: TPanel;
    DBGrid1: TDBGrid;
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    TabSheet3: TTabSheet;
    TabSheet4: TTabSheet;
    TabSheet5: TTabSheet;
    TabSheet6: TTabSheet;
    TabSheet7: TTabSheet;
    TabSheet8: TTabSheet;
    TabSheet9: TTabSheet;
    Memo1: TMemo;
    Label1: TLabel;
    add: TSpeedButton;
    del: TSpeedButton;
    run: TSpeedButton;
    save: TSpeedButton;
    Table1: TTable;
    Memo2: TMemo;
    Memo3: TMemo;
    Memo4: TMemo;
    Memo5: TMemo;
    Memo6: TMemo;
    Memo7: TMemo;
    Memo8: TMemo;
    Memo9: TMemo;
    SaveDialog1: TSaveDialog;
    Label2: TLabel;
    procedure runClick(Sender: TObject);
    procedure addClick(Sender: TObject);
    procedure delClick(Sender: TObject);
    procedure saveClick(Sender: TObject);
    procedure DBGrid1KeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.runClick(Sender: TObject);
var
  i,j,k:Integer;
  tab1,tab2:array[1..5]of byte;//放5个号码
  qishu:String;
  a,b,c,d,e,ncf:byte;
  memo:array[1..9]of TMemo;
  tempa,tempb,tempc,tempd,tempe,tempjy,tempjw,tempcy,tempcw:Int64;
  jw,jy,cw,cy:Char;
begin
if Table1.RecordCount >= 1 then//--------条数比1 大开始------------
begin
  memo[1]:=Memo1; memo[2]:=Memo2; memo[3]:=Memo3; memo[4]:=Memo4;
  memo[5]:=Memo5; memo[6]:=Memo6; memo[7]:=Memo7; memo[8]:=Memo8;
  memo[9]:=Memo9;
  for i:=1 to 9 do
  begin
    memo[i].Clear;
    memo[i].Lines.Add('                         *'+intTostr(i)+'次方运行结果*');
  end;

  Table1.first;//记录回到第0行
  for i:= 1 to 5 do
    tab2[i]:=Table1.Fields.Fields[i].Value;//先把第一条记录放入tab2
//--------------------------------------------------------------------
  for i:=0 to table1.RecordCount-1 do //从第0条到 总条数-1 ---------------------
  begin
    qishu:=Table1.Fields.Fields[0].Value;
    if i<>table1.RecordCount-1 then  //不是最后一条
    begin
      tab1:=tab2;  //把记录1放入记录2;
      Table1.Next; //记录下移一条
      for j:=1 to 5 do
        tab2[j]:=table1.Fields.Fields[j].Value; //记录2取得下一条的数据
    end
    else if i=table1.RecordCount-1 then //是最后一条,只要得出杀几即可
      tab1:=tab2;

    //---------------------以上初始化---------------------------------
    //--------------------以下进行每一次方的判断----------------------
    for j:=1 to 9 do //1 到9 次方
    begin//------1__9 开始--------------------------------
      memo[j].Lines.Append(qishu+': ');//      //写入期数
      for a:=1 to 4 do //-----两个数
        for b:=(a+1) to 5 do
        begin
          tempa:=1;  tempb:=1;  tempjy:= 1 ; tempcy:=1  ;
          for ncf:= 1 to j do
          begin
            tempa:=tempa * tab1[a];
            tempb:=tempb * tab1[b];
            tempjy:=tempjy * (tab1[a] + tab1[b]);//(a+b);
            tempcy:=tempcy * (tab1[a] * tab1[b]);//(a * b)
          end;
          //---------以上取得四种结果----以下进行取个位--------
          tempjw:=strToint(RightStr (intTostr(tempa + tempb),1) ) ;//a + b 的个位
          tempcw:=strToint(RightStr (intTostr(tempa * tempb),1) );//a * b 的个位
          tempjy:=StrToInt(RightStr(intTostr(tempjy),1)); //(a+b)的个位
          tempcy:=StrToInt(RightStr(intTostr(tempcy),1)); //(a*b)的个位
          //---------------------------------------------------------
          if i<>Table1.RecordCount-1 then//不是最后一条,要进行检验
          begin// 不是最后一条开始
            for k:=1 to 3 do //
              if tempjw = tab2[k] then
              begin
                jw:='x';
                Break;
              end
              else
                jw:='v';

              for k:=1 to 3 do //
              if tempjy = tab2[k] then
              begin
                jy:='x';
                Break;
              end
              else
                jy:='v';

              for k:=1 to 3 do //
              if tempcw = tab2[k] then
              begin
                cw:='x';
                Break;
              end
              else
                cw:='v';

              for k:=1 to 3 do //
              if tempcy = tab2[k] then
              begin
                cy:='x';
                Break;
              end
              else
                cy:='v';
            //--------------以下写入文件-------------------
            memo[j].Lines.Strings[i+1]:=memo[j].Lines.Strings[i+1]+
                   intTostr(a)+ '+' +intTostr(b)+ '\' +intTostr(tempjw) + jw +' '+
                   '(' + intTostr(a)+ '+' +intTostr(b)+ ')\' +intTostr(tempjy) + jy +' '+
                   intTostr(a)+ '*' +intTostr(b)+ '\' +IntToStr(tempcw) + cw +' '+
                   '(' + intTostr(a)+ '*' +intTostr(b)+ ')\' +intTostr(tempcy) + cy +' ';

          end //不是最后一条结束
          else if i = Table1.RecordCount-1 then //是最后一条,只写入杀的数,不判断对错
            memo[j].Lines.Strings[i+1]:=memo[j].Lines.Strings[i+1]+
                   intTostr(a)+ '+' +intTostr(b)+ '\' +intTostr(tempjw) + '?' +' '+
                   '(' + intTostr(a)+ '+' +intTostr(b)+ ')\' +intTostr(tempjy) + '?' +' '+
                   intTostr(a)+ '*' +intTostr(b)+ '\' +IntToStr(tempcw) + '?' +' '+
                   '(' + intTostr(a)+ '*' +intTostr(b)+ ')\' +intTostr(tempcy) + '?' +' ';

        end;//---------两个数 结尾--------------------------------
//--------------------------------以下进行三个数的判断-----------------------
      for a:=1 to 3 do
        for b:=(a+1) to 4 do
          for c:=(b+1) to 5 do
          begin
          tempa:=1;  tempb:=1; tempc:=1; tempjy:= 1 ; tempcy:=1  ;
          for ncf:= 1 to j do
          begin
            tempa:=tempa * tab1[a];
            tempb:=tempb * tab1[b];
            tempc:=tempc * tab1[c];
            tempjy:=tempjy * ( tab1[a] + tab1[b] + tab1[b] );//(a+b+c);
            tempcy:=tempcy * ( tab1[a] * tab1[b] * tab1[c] );//(a * b *c)
          end;
          //---------以上取得四种结果----以下进行取个位--------
          tempjw:=strToint(RightStr (intTostr(tempa + tempb + tempc),1) ) ;//a + b+c 的个位
          tempcw:=strToint(RightStr (intTostr(tempa * tempb * tempc),1) );//a * b *c 的个位
          tempjy:=StrToInt(RightStr(intTostr(tempjy),1)); //(a+b)的个位
          tempcy:=StrToInt(RightStr(intTostr(tempcy),1)); //(a*b)的个位
          //---------------------------------------------------------
          if i<>Table1.RecordCount-1 then//不是最后一条,要进行检验
          begin// 不是最后一条开始
            for k:=1 to 3 do //
              if tempjw = tab2[k] then
              begin
                jw:='x';
                Break;
              end
              else
                jw:='v';

              for k:=1 to 3 do //
              if tempjy = tab2[k] then
              begin
                jy:='x';
                Break;
              end
              else
                jy:='v';

              for k:=1 to 3 do //
              if tempcw = tab2[k] then
              begin
                cw:='x';
                Break;
              end
              else
                cw:='v';

              for k:=1 to 3 do //
              if tempcy = tab2[k] then
              begin
                cy:='x';
                Break;
              end
              else
                cy:='v';

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -