Desktop / laba3_Osichev
.docxprocedure TForm1.Button1Click(Sender: TObject);
var f:textfile;
a:array[1..2,1..8] of integer;
i,i1,i2,L,j1,j2,m,s,buf:integer;
begin
assignfile(f,'fff.txt');
reset(f);
i:=0;
while not eof(f) do
begin
inc(i);
read(f,a[1,i]);
edit1.text:=edit1.text+inttostr(a[1,i])+' ';
end;
closeFile(f);
l:=1;
s:=1; m:=2;
while l<8 do
begin
j1:=0;
j2:=L;
i1:=1;
i2:=L+1;
for i:=1 to 8 do
begin
if (i1>j1+L) and (i2>j2+L) then
begin
j1:=j1+2*L;
j2:=j2+2*L;
i1:=i1+L;
i2:=i2+L;
end;
if i1>j1+L then
begin
a[m,i]:=a[s,i2];
inc(i2);
end
else if i2>j2+L then
begin
a[m,i]:=a[s,i1];
inc(i1);
end
else if a[s,i1]>a[s,i2] then
begin
a[m,i]:=a[s,i2];
inc(i2);
end
else
begin
a[m,i]:=a[s,i1];
inc(i1);
end;
end;
L:=L*2;
buf:=m;
m:=s;
s:=buf;
end;
for i:=1 to 8 do
edit2.text:=edit2.text+inttostr(a[s,i])+' ';
end;
end.