unit
Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Grids,Math;
type
TDirection=(drLeft,drRight,drUp,drDown,drRightUp,drRightDown,drLeftUp,drLeftDown);
TForm1 =
class
(TForm)
StringGrid1: TStringGrid;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
procedure
Button1Click(Sender: TObject);
private
public
end
;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure
TForm1
.
Button1Click(Sender: TObject);
const
n=
7
;
m=
6
;
d=
1
;
lock=
50
;
type
ArrDir=
array
of
TDirection;
Matrix=
array
[
1..
n,
1..
m]
of
integer
;
var
A:Matrix;
k,i,j,Rand1,Rand2:
integer
;
begin
FillChar(A,SizeOf(A),
0
);
for
i:=
1
to
High(a)
do
for
j:=
1
to
High(a)
do
StringGrid1
.
Cells[i,j]:=IntToStr(a[i,j]);
for
k:=
1
to
3
do
begin
Rand1:=RandomRange(
1
,
8
);
Rand2:=RandomRange(
1
,
7
);
StringGrid1
.
Cells[Rand1,Rand2]:=IntToStr(lock);
end
;
StringGrid1
.
Cells[
1
,
6
]:=IntToStr(d);
end
;
end
.