unit
Unit1;
interface
uses
Winapi
.
Windows, Winapi
.
Messages, System
.
SysUtils, System
.
Variants,
System
.
Classes, Vcl
.
Graphics,
Vcl
.
Controls, Vcl
.
Forms, Vcl
.
Dialogs, Vcl
.
Grids, Vcl
.
StdCtrls;
type
TForm1 =
class
(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Button1: TButton;
Button2: TButton;
Button3: TButton;
Label1: TLabel;
Label2: TLabel;
procedure
Button1Click(Sender: TObject);
procedure
Button2Click(Sender: TObject);
procedure
Button3Click(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
const
n =
5
;
implementation
{$R *.dfm}
Type
Matrix =
array
[
1
..
5
,
1
..
5
]
of
real
;
vect =
array
[
1
..
5
]
of
integer
;
Var
a: Matrix;
s:
real
;
procedure
TForm1
.
Button1Click(Sender: TObject);
var
sm, smax, sd:
string
;
j, i, ier, imax, jmax:
integer
;
max:
real
;
begin
for
j :=
0
to
4
do
begin
for
i :=
0
to
4
do
if
Length(StringGrid1
.
Cells[i ,j]) <>
0
then
a[i,
1
] := strtofloat(StringGrid1
.
Cells[i ,j])
else
a[i, j] :=
0
;
end
;
for
i :=
0
to
n-
1
do
begin
s :=
0
;
for
j :=
0
to
n-
1
do
begin
s := s + strtofloat(StringGrid1
.
Cells[j, i])*strtofloat(StringGrid1
.
Cells[n - j +
1
, j]);
end
;
StringGrid2
.
Cells[i,
1
] := floattostr(s);
end
;
end
;
procedure
TForm1
.
Button2Click(Sender: TObject);
var
j, i:
integer
;
begin
for
i :=
0
to
n-
1
do
for
j :=
0
to
n-
1
do
StringGrid1
.
Cells[j, i] := inttostr(random(
10
));
for
j :=
0
to
4
do
StringGrid2
.
Cells[j ,
1
] :=
''
;
end
;
procedure
TForm1
.
Button3Click(Sender: TObject);
begin
close;
end
;
end
.