j:= j + 1;
d[j]:= a [i, fn];
end;
if sd then
begin
Sdvig (d, j);
j:= 0;
for i:= fn to m do
begin
j:= j + 1;
a [fn, i]:= d[j];
end;
for i:= fn + 1 to n do
begin
j:= j + 1;
a [i, m]:= d[j];
end;
for i:= m – 1 downto fn do
begin
j:= j + 1;
a [n, i]:= d[j];
end;
for i:= n – 1 downto fn + 1 do
begin
j:= j + 1;
a [i, fn]:= d[j];
end;
end;
Inc(k);
SloiColor (fn + 1, n – 1, m – 1, sd);
end;
end;
procedure TForm1.MQuitClick (Sender: TObject);
var
fi: integer;
begin
fi:= Application. MessageBox ('Вы действительно хотите завершить программу?',
'Информация', mb_YesNo); // вывод окна
if fi = IDYes then
Application. Terminate; // выход
end;
procedure TForm1.MOpenFileClick (Sender: TObject);
// открытьфайлданных
var
n, m, i, j: integer;
f: textfile;
begin
if OpenDialog1. Execute then
begin
mf:= OpenDialog1. FileName;
MRun. Enabled:= True;
AssignFile (f, mf); Reset(f);
ReadLn (f, n, m);
for i:= 1 to n do
begin
for j:= 1 to m do
Read (f, a [i, j]);
ReadLn(f);
end;
CloseFile(f);
for i:= 1 to n do
for j:= 1 to m do
c [i, j]:= clBlack;
k:= 1;
SloiColor (1, n, m, false);
FillGrid (a, n, m);
end;
end;
procedure TForm1. FillGrid (a: mat; n, m: integer);
var
i, j: integer;
r: trect;
begin
StringGrid1. Refresh;
for i:= 1 to 10 do
StringGrid1. Cells [i, 0]:= «;
for i:= 1 to 10 do
begin
StringGrid1. Cells [0, i]:= «;
for j:= 1 to 10 do
begin
r:= StringGrid1. CellRect (j, i);
StringGrid1. Canvas. TextOut (r.topleft.x + 1, r. Top + 2, ' ');
end;
end;
for i:= 1 to m do
StringGrid1. Cells [i, 0]:= IntToStr(i);
for i:= 1 to n do
begin
StringGrid1. Cells [0, i]:= IntToStr(i);
for j:= 1 to m do
begin
StringGrid1. Canvas. Font. Color:= c [i, j];
r:= StringGrid1. CellRect (j, i);
StringGrid1. Canvas. TextOut (r.topleft.x + 1, r. Top + 2, IntToStr (a[i, j]));
end;
end;
StringGrid1. Canvas. Refresh;
end;
procedure TForm1.MRunClick (Sender: TObject);
var
i, j, n, m: integer;
f: textfile;
begin
AssignFile (f, mf); Reset(f);
ReadLn (f, n, m);
CloseFile(f);
for i:= 1 to n do
for j:= 1 to m do
c [i, j]:= clBlack;
k:= 1;
SloiColor (1, n, m, true);
FillGrid (a, n, m);
Append(f);
WriteLn(f);
for i:= 1 to n do
begin
for j:= 1 to m do
Write (f, a [i, j]:5);
WriteLn(f);
end;
CloseFile(f);
end;
end.