最大连续长度

  • 2020-01-19 14:58
  • 澳门新葡亰平台官网下载
  • Views

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.

最大连续长度