我给出三个字符串: abc怎样知道他的全部排制方式, 比如:a, b, c, aa, ab, ac, ba, bb, bc, ca.....等,请高手指点!谢谢!

解决方案 »

  1.   

    procedure AllList(FullStr: String; ResultStr: String; MaxLength: Integer);
    var
      I: Integer;
    begin
      if Length(ResultStr) = MaxLength then
      begin
        Writeln(ResultStr);
        Exit;
      end;  for I := 1 to Length(FullStr) do
      begin
        if Pos(FullStr[I], ResultStr) = 0 then
          AllList(FullStr, ResultStr + FullStr[I], MaxLength);
      end;
    end;
    调用
    var
      I: Integer;
      S: String;
    begin
      S := 'abcdefgh';
      for I := 1 to Length(S) do
        AllList(S, '', I);
      readln;
    end.