function ResultBuf(N: array of string): string;var i, j, k, K1, x, y, Max, Min: Integer;
s: string;
M: array of string;
begin
Max := High(N);
Min := Low;
k := 0;
for i := Min to Maxdo
begin
SetLength(M, Length(M) + 1);
m[Length(M) - 1] := N;
Inc(K);
end;
x := 0;
K1 := 0;
for y := Min to Max - 1do
begin
K1 := 0;
for i := Min + x to Min + x + K - 1do
begin
for j := Min to Maxdo
begin
if pos(N[j], M) = 0 then
begin
SetLength(M, Length(M) + 1);
m[Length(M) - 1] := M + N[j];
Inc(K1);
end;
end;
end;
x := x + k;
k := K1;
end;
for i := 0 to Length(M) - 1do
begin
Result := Result + '|' + M;
end;
end;
procedure TForm1.btn1Click(Sender: TObject);var a, b, c, d: string;
s: string;
begin
a := 'a';
b := 'b';
c := 'c';
d := 'd';
s := ResultBuf([a, b, c,d]);
ShowMessage(s);
end;
改正后的
LZ看下是不是这样的 看出来有点问题,改好后在发上来 本楼代码有问题,正确的见楼下function ResultBuf(N: array of string): string;var i, j, k, K1, x, Max, Min: Integer;
s: string;
M: array of string;
begin
Max := High(N);
Min := Low;
k := 0;
for i := Min to Maxdo
begin
SetLength(M, Length(M) + 1);
m[Length(M) - 1] := N;
Inc(K);
end;
for x := Min to Maxdo
begin
for i := Min + length(N) * x to K + length(N) * x - 1do
begin
for j := Min to Maxdo
begin
if pos(N[j], M) = 0 then
begin
SetLength(M, Length(M) + 1);
m[Length(M) - 1] := M + N[j];
Inc(K1);
end;
end;
end;
end;
for i := 0 to Length(M) - 1do
begin
Result := Result + '|' + M;
end;
end;
procedure TForm1.btn1Click(Sender: TObject);var a, b, c, d: string;
s: string;
begin
a := 'a';
b := 'b';
c := 'c';
d := 'd';
s := ResultBuf([a, b, c]);
ShowMessage(s);
end;