, si: set of byte;
sw1 , sw2 , sw3: string;; (f, 'rez.txt'); (f); (f , 'введені рядки');
writeln (f, '***********************'); i: = 1 to n do
begin
s: ='';
for j: = 1 to sx [i] do s: = s + a [i, j] + '+';
delete (s, length (s), 1);
writeln (f, s, '<-', i, ' - я рядок ');
end; (f, '***********************'); q: = 1 to n do
begin
s: ='';
si: = [];
include (si, q);
for j: = 1 to sx [q] do s: = s + a [q, j];
sw1: ='';
cop (sw1, s);
writeln (f , sw1, '<- вихідна рядок ');
repeat
b: = false;
for i: = 1 to n do
begin
if not (i in si) then
begin
sj: = [];
sw1: ='';
cop (sw1, s);
for j: = 1 to sx [i] do
begin
x: = a [i, j];
h: = length (x);
if h = 2 then
begin
delete (x, 1,1);
dec (h)
end
else
begin
insert ('^' , x, 1);
inc (h)
end;
k: = pos (x, s);
if (k> 0) and (s [k - 1] = '^') and (a [i , j] = copy (s, k - 1,2)) then
begin
k: = 0;
sj: = sj + [j];
end
else if k> 0 then
begin
sj1: = sj1 + [j];
delete (s, k, h)