首页  编辑  

全排列

Tags: /超级猛料/Friends.网友专栏/zswang/函数大全/   Date Created:

123

132

213

231

312

321

function ZsList(mStr: string): string; { 全排列 }

 procedure pZsList(mLeft, mRight: string);

 var

   I, L: Integer;

   Temp: string;

 begin

   L := Length(mLeft);

   if L = 0 then

     Result := Result + mRight + #13#10

   else for I := 1 to L do begin

     Temp := mLeft;

     Delete(Temp, I, 1);

     pZsList(Temp, Concat(mRight, mLeft[I]));

   end;

 end; { [ZsList<pZsList>] }

begin

 Result := '';

 pZsList(mStr, '');

end; { ZsList }