主题:版主、长尾兔。请教如何改写这个程序令它简单快速?
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i1,i2,i3,i4,i5,i6:integer;
s:string;
begin
for i1:=1 to 28 do
for i2:=i1+1 to 29 do
for i3:=i2+1 to 30 do
for i4:=i3+1 to 31 do
for i5:=i4+1 to 32 do
for i6:=i5+1 to 33 do begin
s:=inttostr(i1)+inttostr(i2)+inttostr(i3)+inttostr(i4)+inttostr(i5)+inttostr(i6);
listbox1.Items.Add(s);
end;
label1.Caption:=inttostr(listbox1.Count);
end;
end.
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i1,i2,i3,i4,i5,i6:integer;
s:string;
begin
for i1:=1 to 28 do
for i2:=i1+1 to 29 do
for i3:=i2+1 to 30 do
for i4:=i3+1 to 31 do
for i5:=i4+1 to 32 do
for i6:=i5+1 to 33 do begin
s:=inttostr(i1)+inttostr(i2)+inttostr(i3)+inttostr(i4)+inttostr(i5)+inttostr(i6);
listbox1.Items.Add(s);
end;
label1.Caption:=inttostr(listbox1.Count);
end;
end.