unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Edit1: TEdit;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Type TMatr=array [1..50] of array [1..50] of real;
var matr:TMatr;
n,m:integer;
implementation
{$R *.dfm}
Procedure Vvod(var Matr:TMatr; n,m:integer);
var i,j:integer;
begin
Randomize;
for i:=0 to n-1 do
for j:=0 to m-1 do
Matr[i,j]:=Int(random*40)-20;
end;
Procedure Vivod(var Matr:TMatr;n,m:integer;StringGrid1:TstringGrid);
var i,j:integer;
begin
for i:= 0 to n-1 do
for j:=0 to m-1 do
StringGrid1.Cells[j,i]:=FloatToStr(Matr[i,j]);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
StringGrid1.RowCount := strtoint(edit1.text);
StringGrid1.ColCount := strtoint(edit1.text);
n:= strtoint(edit1.text);
m:= strtoint(edit1.text);
Vvod(Matr,n,m);
Vivod(Matr,n,m,StringGrid1);
end;
end.