unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids;
type
TForm1 =
class
(TForm)
StringGrid1: TStringGrid;
StringGrid2: TStringGrid;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Button2: TButton;
procedure
Button1Click(Sender: TObject);
procedure
Button2Click(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
a:
array
[
1..15
,
1..15
]
of
integer
;
n,m:
integer
;
implementation
{$R *.dfm}
procedure
TForm1
.
Button1Click(Sender: TObject);
var
k:
integer
;
begin
val
(Edit1
.
Text,n,k);
n:=
2
*n+
1
;
StringGrid1
.
RowCount:=n;
StringGrid1
.
ColCount:=n;
m:=
4
*(n-
1
)+
1
;
StringGrid2
.
ColCount:=m;
StringGrid1
.
Options:=StringGrid1
.
Options+[goEditing,goTabs];
ShowMessage(
'Введите в таблицу 1 элементы матрицы, целые числа '
);
end
;
procedure
TForm1
.
Button2Click(Sender: TObject);
var
i,j,k:
integer
;
begin
for
i:=
1
to
n
do
for
j:=
1
to
n
do
begin
val
(StringGrid1
.
Cells[j-
1
,i-
1
],a[i,j],k);
if
k<>
0
then
ShowMessage(
'В ячейке ['
+inttostr(i)+
','
+inttostr(j)+
'] неверно введено число, поправьте'
);
end
;
for
i:=
1
to
n-
1
do
begin
StringGrid2
.
Cells[i-
1
,
0
]:=inttostr(a[
1
,i]);
StringGrid2
.
Cells[n+i-
2
,
0
]:=inttostr(a[i,n]);
StringGrid2
.
Cells[
2
*n+i-
3
,
0
]:=inttostr(a[n,n-i+
1
]);
StringGrid2
.
Cells[
3
*n+i-
4
,
0
]:=inttostr(a[n-i+
1
,
1
]);
end
;
StringGrid2
.
Cells[m-
1
,
0
]:=inttostr(a[n
div
2
+
1
,n
div
2
+
1
]);
end
;
end
.