procedure TForm1.Button1Click(Sender: TObject);
var
strs :TStrings;
s,s2,s1,s3:string;
i,t,g,t1,g1:Integer;
begin
s:='';
t:=0;
g:=0;
t1:=0;
g1:=0;
strs := TStringList.Create;
strs.DelimitedText:='3,4,5,9,11,15,16,18,20,21,22,24,26,56,54,87,77,53,21,55,45,99,75 ';
for i:=0 to Strs.Count-1do
begin
if (strtoint(Strs) mod 2)=0 then
begin
S:=S+Strs+',';
t:=t+1;
if (t1>1) and (t1>g1) then
begin
s3:=s1;
g1:=t1;
end;
s1:='';
t1:=0;
end;
if ((strtoint(Strs) mod 2)=1) or (i=Strs.Count-1) then
begin
s1:=s1+Strs+',';
t1:=t1+1;
if (t>1)and (t>g) then
begin
s2:=s;
g:=t;
end;
s:='';
t:=0;
end;
if (i=Strs.Count-1) then
begin
if (t1>1) and (t1>g1) then
begin
s3:=s1;
g1:=t1;
end;
s1:='';
t1:=0;
end;
end;
ShowMessage('最多的连续偶数是 '+s2+'('+inttostr(g)+'个)'+#10+'最多的连续奇数是 '+s3+'('+inttostr(g1)+'个)');
strs.Free;
end;