在我的机子上,上铺的代码通不过,我的是5.X
我修改了一下
但是还有问题
var Strs:TStringList;
I,Count,m,n,l:Integer;
Loops:Array of Integer;
abc,Str:String;
begin
Strs:=TStringList.Create;
try
// Strs.Delimiter:='*';
abc:=Edit1.Text;
strs.text :=StringReplace(abc,'*',#13#10,[rfReplaceAll]);
Count:=Strs.Count;
SetLength(Loops,Count);
Memo1.Clear;n:=0;
for I:=0 to Count-1 do Loops:=I;
while true do
begin
Str:='';
for I:=0 to Count-1 do Str:=Str+'*'+Strs[Loops];
Str:=Copy(Str,2,Length(Str));
Memo1.Lines.Append(Str);
m:=-1;
for I:=Count-1 downto 1 do
if Loops>Loops[I-1] then begin m:=I-1
break
end;
if m=-1 then Break;
for I:=Count-1 downto m do
if Loops>Loops[m] then begin n:=I;break
end;
Loops[m]:=Loops[m]+Loops[n];Loops[n]:=Loops[m]-Loops[n];Loops[m]:=Loops[m]-Loops[n];
l:=(m+Count-1) Div 2;
for I:=1 to l-m do
begin
Loops[m+i]:=Loops[m+i]+Loops[Count-i];
Loops[Count-i]:=Loops[m+i]-Loops[Count-i];
Loops[m+i]:=Loops[m+i]-Loops[Count-i];
end;
end;
finally
Strs.Free;
end;
end;