在str2中如159,若必含两个数字15,则结果为真,但实际运算有问题: //////////必有两数字 function twoStrInstr(str1:string;str2:String):boolean; var j,k:integer;
begin k:=0; if str1[1]=str1[2] then begin for j:=1 to 3 do if str2[j]=str1[1] then inc(k); if k>=2 then Result:=true; end; if str1[1] <>str1[2] then if (pos(str1[1],str2)>0) and (pos(str1[2],str2)>0) then begin Result:=true; end; end;
procedure TForm1.Button62Click(Sender: TObject); var str1,str2:string; begin str1:='12'; str2:='133'; if twostrInStr(str1,str2) then showmessage('ok'); end;
function twoStrInstr(str1:string;str2:String):boolean;
begin
Result:=(Pos(str1[2],str2)>0) and (Pos(str1[1],str2)>0) and (Pos(str1[2],str2)>Pos(str1[1],str2));
end;
function chk(str1,str2:string):Boolean; var i,j:Integer; begin j:=0; for i:=1 to Length(str1) do begin if (Pos(str1[i],str2) <>0) then inc(j); end; result:=(j>=2); end;