作者在 2011-10-02 09:04:19 发布以下内容
var
len,i:byte;
st:string;
max,now:record
length:byte;
ch:char;
end;
begin
assign(input,'long.in');
reset(input);
assign(output,'long.out');
rewrite(output);
readln(len);
readln(st);
with max do begin
length:=1;
ch:=st[1]
end;
now:=max;
for i:=2 to len do
if st[i]=st[i-1] then inc(now.length) else begin
if now.length>max.length then max:=now;
with now do begin
length:=1;
ch:=st[i]
end
end;
with max do begin
writeln(length);
write(ch)
end;
close(input);
close(output)
end.
最大连续长度len,i:byte;
st:string;
max,now:record
length:byte;
ch:char;
end;
begin
assign(input,'long.in');
reset(input);
assign(output,'long.out');
rewrite(output);
readln(len);
readln(st);
with max do begin
length:=1;
ch:=st[1]
end;
now:=max;
for i:=2 to len do
if st[i]=st[i-1] then inc(now.length) else begin
if now.length>max.length then max:=now;
with now do begin
length:=1;
ch:=st[i]
end
end;
with max do begin
writeln(length);
write(ch)
end;
close(input);
close(output)
end.