如果我要产生 ak 到 kdszdf 3重循环可以吗?

解决方案 »

  1.   

    function ZsLadder(mText: string; mLength: Integer = 0): string; { 阶梯 }
    var
      I, L: Integer;
      S, T: string;
    begin
      Result := '';
      L := Length(mText);
      if L < 1 then Exit;
      if mLength <= 0 then mLength := L; 
      S := '';
      for I := 1 to mLength do S := S + mText[1]; //00000
      T := '';
      for I := 1 to mLength do T := T + mText[L]; //44444  while S <> T do begin
        Result := Result + S + #13#10;
        for I := mLength downto 1 do
          if S[I] = mText[L] then
            S[I] := mText[1]
          else begin
            S[I] := mText[Pos(S[I], mText) + 1];
            Break;
          end;
      end;  Result := Result + S + #13#10;
    end; { ZsLadder }procedure TForm1.Button1Click(Sender: TObject);
    var
      I: Integer;
    begin
      with TStringList.Create do try
        Text := ZsLadder('abcdefghijklmnopqrstuvwxyz', 2);
        Text := Text + ZsLadder('abcdefghijklmnopqrstuvwxyz', 3);    for I := Count - 1 downto IndexOf('jac') + 1 do Delete(I);
        for I := IndexOf('ak') - 1 downto 0 do Delete(I);
        RichEdit1.Text := Text;
      finally
        Free;
      end;
    end;
      

  2.   

    那就是六重呀:)for i:=0 to ord('j')-ord('a') do
    for j:=0 to ord('z')-ord('a') do
    for k:=-1 to ord('z')-ord('a') do
    begin
      if (i = ord('j') - ord('a') ) and ((j > 0) or (k>3) ) then
        break;
      write(chr(i+ord('a')),chr(j+ord('a')) );
      if (k>=0) write(chr(k+ord('a')));
      writeln;
    end;
      

  3.   

    高手,另外,如果我要产生 ak 到 kdszdf 3该怎么做?呵呵。
      

  4.   

    procedure TForm1.Button1Click(Sender: TObject);
    begin
      with TStringList.Create do try
        Text := Text + ZsLadder('abcdefghijklmnopqrstuvwxyz', 1);
        Text := Text + ZsLadder('abcdefghijklmnopqrstuvwxyz', 2);
        Text := Text + ZsLadder('abcdefghijklmnopqrstuvwxyz', 3);
        SaveToFile('C:\Temp.txt');
      finally
        Free;
      end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    var
      I, B, E: Integer;
    begin
      with TStringList.Create do try
        LoadFromFile('C:\Temp.txt');
        B := IndexOf(Edit1.Text);
        E := IndexOf(Edit2.Text);
        for I := Count - 1 downto 0 do if (I > E) or (I < B) then Delete(I);
        RichEdit1.Text := Text;
      finally
        Free;
      end;
    end;
      

  5.   

      Edit1.Text := IntToStr(26 * 26* 26* 26* 26* 26);//308915776308915776//!!!!!!