2 câu trả lời
uses crt,math;
type int = longint;
var a,b,s1,s2:string;
l,i,m,j:int;
begin
clrscr;
readln(a);
readln(b);
l:=length(a);
m:=min(l,length(b));
s1:=a[l];
s2:=b[1];
dec(l);i:=2;
for j:=m downto 1 do
begin
if s1 <> s2 then
begin
s1:=a[l] + s1;
s2:=s2 + b[i];
dec(l);inc(i);
end
else
break;
end;
if s1 <> s2 then writeln('khong co')
else writeln(s1);
readln;
end.
var x,y,s,s1,s2:ansistring;
i,j,n:longint;
begin
readln(x);
read(y);
for i := 1 to length(x) do
if pos(x[i],s1) = 0 then
s1 := s1 + x[i];
for j := 1 to length(y) do
if pos(y[j],s2) = 0 then
s2 := s2 + y[j];
for i := 1 to length(s1) do
for j := 1 to length(s2) do
if s1[i] = s2[j] then
s := s+s1[i];
writeln(s);
readln; readln;
end.