unit3.pas

来自「SourceCode for Delphi. multiplex matrix」· PAS 代码 · 共 74 行

PAS
74
字号
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, StdCtrls;

type
  vector=array [1..20,1..20] of real;
  TForm1 = class(TForm)
    Label1: TLabel;
    Edit1: TEdit;
    Label2: TLabel;
    StringGrid1: TStringGrid;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Label4: TLabel;
    procedure StringGrid1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  l:integer;

implementation

{$R *.dfm}

procedure max(vr:vector;var max:real);
 var i,j:integer;
 begin
  max:=1;
  for i:=1 to l do
  for j:=1 to l do
   if (vr[i,j]<>0) and (i<>j) and (j<>l-i+1) then
   max:=max* vr[i,j];
 end;

procedure TForm1.StringGrid1Click(Sender: TObject);
 begin
  stringgrid1.RowCount:=strtoint(edit1.Text);
  stringgrid1.ColCount:=strtoint(edit1.Text);
 end;

procedure TForm1.Button2Click(Sender: TObject);
 begin
  close();
 end;

procedure TForm1.Button1Click(Sender: TObject);
var
t:vector;
i,j:integer;
u:real;
 begin
  l:=strtoint(edit1.Text);
  for i:=1 to l do
   for j:=1 to l do
    if stringGrid1.Cells[j-1,i-1]<>'' then
    t[i,j]:=StrTofloat
   (StringGrid1.Cells[j-1,i-1]) else exit;
    max(t,u);
   label4.Caption:=floattostr(u);
 end;
 end.

⌨️ 快捷键说明

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