O
ooooh
Unregistered / Unconfirmed
GUEST, unregistred user!
请大家先运行一下这程序看清结果,然后再提出修改方法.
能否用递归,矩阵呢? 最简单最好是什么方法? 烦请给出实例.
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
listbox1.Clear;
for i1:=0 to 4 do
for i2:=i1+1 to 5 do
for i3:=i2+1 to 6 do
for i4:=i3+1 to 7 do
for i5:=i4+1 to 8 do
for i6:=i5+1 to 9 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.
能否用递归,矩阵呢? 最简单最好是什么方法? 烦请给出实例.
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
listbox1.Clear;
for i1:=0 to 4 do
for i2:=i1+1 to 5 do
for i3:=i2+1 to 6 do
for i4:=i3+1 to 7 do
for i5:=i4+1 to 8 do
for i6:=i5+1 to 9 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.