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
i:=
1
to
5
do
if
Length(Stringgrid1
.
Cells[i-
1
,
0
])<>
0
<font color="Red">
then
a[i]:= strtofloat(stringgrid1
.
Cells[i-
1
,
0
])
else
a[i,j]:=
0
; </font>
for
i:=
1
to
n
do
begin
s:=
0
;
for
j:=
1
to
n
do
s:=s+strtofloat(StringGrid1
.
cells[j,i]);
strtofloat(stringgrid1
.
cells[n-j+
1
,j]);
stringgrid2
.
cells[i,
1
]:=floattostr(s);
end
;
end
;
procedure
TForm1
.
Button2Click(Sender: TObject);
var
j, i:
integer
;
begin
for
i:=
1
to
n
do
for
j:=
1
to
n
do
stringgrid1
.
cells[j,i]:=
' '
;
for
j:=
1
to
5
do
stringgrid2
.
cells[j-
1
,
1
]:=
' '
;
end
;
procedure
TForm1
.
Button3Click(Sender: TObject);
begin
close;
end
;
end
.