最大连续组长度

作者在 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.
最大连续长度
默认分类 | 阅读 338 次
文章评论,共0条
游客请输入验证码
文章分类
文章归档
最新评论