16,742
社区成员
发帖
与我相关
我的任务
分享function StringMaxCnt(str:string;strSour:TStrings):integer;
var
i,d,max,p:integer;
begin
max:=-1;
p:=-1;
for i:=0 to strSour.Count-1 do
if strSour[i]=str then
begin
if p=-1 then p:=i else
begin
d:=i-p;
p:=i;
if max <d then max:=d;
end;
end;
result:=max;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
temps2:TStringList;
d:integer;
begin
Temps2:=TStringList.Create;
temps2.add('123');
temps2.add('523');
temps2.add('127');
temps2.add('123');
temps2.add('223');
temps2.add('523');
temps2.add('127');
temps2.add('123');
d:=StringMaxCnt('123',temps2);
showmessage(inttostr(d));
temps2.free;
end;