5,392
社区成员
发帖
与我相关
我的任务
分享
procedure TForm1.Calc(M : array of Integer);
var
N : Integer;
A : array of Integer;
i , p: Integer;
X : Integer;
S : String;
begin
N := Length(M);
SetLength(A, N);
for X := 0 to N - 1 do
begin
for i := 0 to N - 1 do A[i] := -1;
p := 0;
while p >= 0 do
begin
if A[p] = -1 then
begin
if p = 0 then
A[p] := 0
else
A[p] := A[p - 1] + 1;
end
else
inc(A[p]);
if A[p] >= N then
begin
A[p] := -1;
dec(p);
end
else begin
inc (p);
if p > X then
begin
S := '';
for i := 0 to X do
begin
if s <> '' then s := S + ',';
S := S + IntToStr(M[A[i]]);
end;
memo1.Lines.Add(S);
dec(p);
end;
end;
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
M : array [0..3] of Integer = (1, 2, 3, 4);
begin
Calc(M);
end;
function TestBit(Value, Index : integer) : Boolean;
asm
BT EAX, EDX
SBB EAX, EAX
AND EAX, 1
end;
procedure TForm1.Button1Click(Sender: TObject);
const
A : array[0..4] of Char = ('A','B','C','D','E');
var
I, J: Integer;
Temp: string;
begin
for I := 1 to 31 do begin
Temp := '';
for J := Low(A) to High(A) do
if TestBit(I, J) then Temp := Temp + A[J];
Memo1.Lines.Add(Temp);
end;
end;