если ти имеешь ввиду то что я набрал то вот ето чудо
Код
type
tfile = file of integer;
var
t,p: integer;
a,b,c,d: tfile;
f,fsort: boolean;
{--Sorting: realizing mearge sort. return status end of sorting--}
function sort(var a,b,c,d: tfile): boolean;
var
fi,fj,i,j,ta,tb,pa,pb: integer;
begin
i:=2;j:=2;
reset(a); reset(b); rewrite(c); rewrite(d);
while (i<=filesize(a)) and (j<=filesize(b)) do begin
seek(a,i-2); seek(b,j-2); read(a,pa); read(b,pb);
seek(a,i-1); seek(b,j-1); read(a,ta); read(b,tb);
while (ta>=pa) and (tb>=pb) and (i<=filesize(a)) and (j<=filesize(b)) do begin
seek(a,i-2); seek(b,j-2); read(a,pa); read(b,pb);
seek(a,i-1); seek(b,j-1); read(a,ta); read(b,tb);
if f then if ta>tb then begin write(c,tb); inc(j); end
else begin write(c,ta); inc(i); end
else if ta>tb then begin write(d,tb); inc(j); end
else begin write(d,ta); inc(i); end;
end;
seek(a,i-2); seek(b,j-2); read(a,pa); read(b,pb);
seek(a,i-1); seek(b,j-1); read(a,ta); read(b,tb);
while ((ta>=pa) or (tb>=pb)) and (i<=filesize(a)) and (j<=filesize(b)) do begin
seek(a,i-2); seek(b,j-2); read(a,pa); read(b,pb);
seek(a,i-1); seek(b,j-1); read(a,ta); read(b,tb);
if f then begin
if ta>=pa then begin write(c,ta); inc(i); end;
if tb>=pb then begin write(c,tb); inc(j); end;
end else begin
if ta>=pa then begin write(d,ta); inc(i); end;
if tb>=pb then begin write(d,tb); inc(j); end;
end;
end;
end;
close(a); close(b); close(c); close(d);
end;
begin
{--Initialization: assigning and make file b.txt--}
assign(a,'a.txt'); assign(b,'b.txt'); assign(c,'c.txt'); assign(d,'d.txt');
rewrite(b); close(b);
{--First read: data moved from a to c and d--}
assign(input,'a.txt'); reset(input);
assign(c,'c.txt'); reset(c);
assign(d,'d.txt'); reset(d);
f:=true;
read(t);
while not eof do begin
p:=t;
read(t);
if f then write(c,p) else write(d,p);
if p>t then f:=not f;
end;
if p>t then f:=not f;
if f then write(c,t) else write(d,t);
close(input); close(c); close(d);
{--Haupt sorting: using procedure sort with either params--}
f:=true; fsort:=false;
while not fsort do begin
if f then fsort:=sort(c,d,a,b) else fsort:=sort(a,b,c,d);
f:=not f;
end;
{--Preperer to out: moving result file in c.txt--}
reset(a); rewrite(c);
if not f then
while not eof(a) do begin
read(a,t);
write(c,t);
end;
close(a); close(c);
{--Output: export all digits data from c.txt in a.txt--}
assign(output,'a.txt');
rewrite(output); reset(c);
while not eof(c) do begin
read(c,t);
write(t);
end;
close(output); close(c);
end.
по моему в условиях даже ответ не верен - щас тока заметил.
А прога моя - даже вижу где ошибки некоторый, но всё больше я сней драться не могу! ХЕЛП!