procedure TForm1.Button1Click(Sender: TObject); var S1,S2,S3,S4,S5,S6,S7 : string; S : string; I1,I2,I3,I4,I5,I6,I7 : integer; begin S1 := IntToStr( 18 ); S2 := IntToStr( 23 ); S3 := IntToStr( 3 ); S4 := IntToStr( 49 ); S5 := IntToStr( 5 ); S6 := IntToStr( 64 ); S7 := IntToStr( 7 ); S := ''; for I7 := 1 to Length(S7) do for I6 := 1 to Length(S6) do for I5 := 1 to Length(S5) do for I4 := 1 to Length(S4) do for I3 := 1 to Length(S3) do for I2 := 1 to Length(S2) do for I1 := 1 to Length(S1) do begin S := S1[I1]+S2[I2]+S3[I3]+S4[I4]+S5[I5]+S6[I6]+S7[I7]; Memo1.Lines.Add(S); end; end;
循环部分改成下面这样吧。 不过其实是一样的道理。 for I1 := 1 to Length(S1) do for I2 := 1 to Length(S2) do for I3 := 1 to Length(S3) do for I4 := 1 to Length(S4) do for I5 := 1 to Length(S5) do for I6 := 1 to Length(S6) do for I7 := 1 to Length(S7) do begin S := S1[I1]+S2[I2]+S3[I3]+S4[I4]+S5[I5]+S6[I6]+S7[I7]; Memo1.Lines.Add(S); end;
var
S1,S2,S3,S4,S5,S6,S7 : string;
S : string;
I1,I2,I3,I4,I5,I6,I7 : integer;
begin
S1 := IntToStr( 18 );
S2 := IntToStr( 23 );
S3 := IntToStr( 3 );
S4 := IntToStr( 49 );
S5 := IntToStr( 5 );
S6 := IntToStr( 64 );
S7 := IntToStr( 7 ); S := '';
for I7 := 1 to Length(S7) do
for I6 := 1 to Length(S6) do
for I5 := 1 to Length(S5) do
for I4 := 1 to Length(S4) do
for I3 := 1 to Length(S3) do
for I2 := 1 to Length(S2) do
for I1 := 1 to Length(S1) do
begin
S := S1[I1]+S2[I2]+S3[I3]+S4[I4]+S5[I5]+S6[I6]+S7[I7];
Memo1.Lines.Add(S);
end;
end;
for I2 := 1 to Length(S2) do
for I3 := 1 to Length(S3) do
for I4 := 1 to Length(S4) do
for I5 := 1 to Length(S5) do
for I6 := 1 to Length(S6) do
for I7 := 1 to Length(S7) do
begin
S := S1[I1]+S2[I2]+S3[I3]+S4[I4]+S5[I5]+S6[I6]+S7[I7];
Memo1.Lines.Add(S);
end;