uses Math; {RandomRange}var
  i, previous, current: Integer;
begin
  previous := Ord('A');
  edt1.Text := '';
  Randomize;
  for i := 0 to 99 do
  begin
    // 随机字母
    current := RandomRange(ord('A'), ord('Z') + 1);
   // 不允许出现连续的 H
    if (current = previous) and (current = ord('H')) then
      Continue;
    previous := current;
    edit1.Text := edit1.Text + chr(current);
  end;
end;

解决方案 »

  1.   

    其实就是,只要这个字符串出现某一个字符,则这个字符的后一个字符就要去掉一次就好了..比如,随机生成了100次的字母,添加到edit1中
    当发现出现这个特定字符时,就去掉这个字符后面的字一次.
      

  2.   

    procedure TForm2.Button1Click(Sender: TObject);
    var
      i, iCounter: Integer;
      ch, preCh : char;
    begin
      memo1.Clear;  Randomize;
      iCounter := 0;
      preCh := ' ';
      for i := 0 to 100 do
      begin
        ch := Chr(Random(26) + 65);    if preCh = 'H' then
        begin
          memo1.Lines.Add(ch + '------------------------');
          inc(iCounter);
        end
        else
          memo1.Lines.Add(ch + ',' + ch);
        preCh := ch;
      end;
      memo1.Lines.Add(format('H出现%d次', [iCounter]));
    end;