Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: us-ascii
Méret: 1 KB
program dns;
const
count = '10';
input = 'lkr'+count+'.be';
output = 'lkr'+count+'.ki';
type
honnan = -1..0;
var
x,y,m : string;
lkr : array [0..100,0..100] of byte;
h : array [0..100,0..100] of record
x,y : honnan;
end;
i,j,a : byte;
f : text;
procedure load;
var
f : text;
begin
Assign(f,input);
Reset(f);
readln(f,x);
readln(f,y);
Close(f);
end;
begin
load;
for i:=0 to 100 do
for j:=0 to 100 do
begin
if (i=0)or(j=0) then lkr[i,j]:=0 else
if x[i]=y[j] then
begin
lkr[i,j]:=lkr[i-1,j-1]+1;
h[i,j].x:=-1;
h[i,j].y:=-1;
end else
if lkr[i-1,j]>lkr[i,j-1] then
begin
lkr[i,j]:=lkr[i-1,j];
h[i,j].x:=-1;
h[i,j].y:=0;
end else
begin
lkr[i,j]:=lkr[i,j-1];
h[i,j].x:=0;
h[i,j].y:=-1;
end;
end;
m:='';
i:=length(x);
j:=length(y);
repeat
a:=i;
if lkr[i,j]>lkr[i+h[i,j].x,j+h[i,j].y] then
m:=x[i]+m;
i:=i+h[i,j].x;
j:=j+h[a,j].y;
until (i=0)or(j=0);
Assign(f,output);
Rewrite(f);
writeln(f,lkr[length(x),length(y)]);
writeln(f,m);
Close(f);
end. of program