求023 |258 |367上次有多少次没有出现?总共出了多少次? 结果283、027含在其内,本次间隔为3 ,上次间隔为2,共出现2次
temps2.Add('027');
temps2.Add('159');
temps2.Add('183');
temps2.Add('283');
temps2.Add('445');
temps2.Add('445');
temps2.Add('445')
用function 求上次间隔,总的出现次数
参考: function StringInAry(str1,str2,str3:string;strSour:string):boolean;
begin
Result:=(Pos(strSour[1],str1)>0) and (Pos(strSour[2],str2)>0) and (Pos(strSour[3],str3)>0)
end;function StringMaxCntInAry(str1,str2,str3:string;strSour:TStrings):integer;
var
i,iMaxCnt,iCnt:Integer;
bFind:boolean;
begin
iCnt:=0;
iMaxCnt:=0;
bFind:=false;
for i:=strSour.Count-1 downto 0 do
begin
if StringInAry(str1,str2,str3,strSour.Strings[i]) then
.....
end;
Result:=iMaxCnt;
end;
temps2.Add('027');
temps2.Add('159');
temps2.Add('183');
temps2.Add('283');
temps2.Add('445');
temps2.Add('445');
temps2.Add('445')
用function 求上次间隔,总的出现次数
参考: function StringInAry(str1,str2,str3:string;strSour:string):boolean;
begin
Result:=(Pos(strSour[1],str1)>0) and (Pos(strSour[2],str2)>0) and (Pos(strSour[3],str3)>0)
end;function StringMaxCntInAry(str1,str2,str3:string;strSour:TStrings):integer;
var
i,iMaxCnt,iCnt:Integer;
bFind:boolean;
begin
iCnt:=0;
iMaxCnt:=0;
bFind:=false;
for i:=strSour.Count-1 downto 0 do
begin
if StringInAry(str1,str2,str3,strSour.Strings[i]) then
.....
end;
Result:=iMaxCnt;
end;
function StringLastCntInAry(str1,str2,str3:string;strSour:TStrings):integer;
var
i,iCnt:Integer;
bFind:boolean;
begin
iCnt:=0;
bFind:=false;
for i:=strSour.Count-1 downto 0 do
begin
if StringInAry(str1,str2,str3,strSour.Strings[i]) then
begin
if iCnt<>0 then
break;
bFind:=true;
end; if bFind then
inc(iCnt);
end;
Result:=iCnt;
end;
上面是上次间隔,计算结果多了一个,改下function StringLastCntInAry(str1,str2,str3:string;strSour:TStrings):integer;
var
i,iCnt:Integer;
bFind:boolean;
begin
iCnt:=0;
bFind:=false;
for i:=strSour.Count-1 downto 0 do
begin
if StringInAry(str1,str2,str3,strSour.Strings[i]) then
begin
if iCnt<>0 then
break;
bFind:=true;
end; if bFind then
inc(iCnt);
end;
Result:=iCnt-1;
end;下面是总出现次数:function StringCntsInAry(str1,str2,str3:string;strSour:TStrings):integer;
var
i,iCnt:Integer;
begin
iCnt:=0;
for i:=strSour.Count-1 downto 0 do
if StringInAry(str1,str2,str3,strSour.Strings[i]) then
inc(iCnt);
Result:=iCnt;
end;