Var n,m:integer; mn:set of integer; b:boolean; begin write('n = '); readln(n); write('m = '); readln(m); mn:=[]; while n>0 do begin mn:=mn+[n mod 10]; n:=n div 10; end; b:=false; while m>0 do begin if (m mod 10) in mn then b:=true; m:=m div 10; end; if b then writeln('Да') else writeln('Нет'); end.
mn:set of integer;
b:boolean;
begin
write('n = '); readln(n);
write('m = '); readln(m);
mn:=[];
while n>0 do
begin
mn:=mn+[n mod 10];
n:=n div 10;
end;
b:=false;
while m>0 do
begin
if (m mod 10) in mn then b:=true;
m:=m div 10;
end;
if b then writeln('Да') else writeln('Нет');
end.
Пример:
n = 13579
m = 6541
Да