再请jeffrey_s解释一个问题 ( 积分: 100 )

S

sq68686

Unregistered / Unconfirmed
GUEST, unregistred user!
你的程序我看过,非常好!可如何从N个数中选7,程序又该作如何改动?再有,排列完后,又该如何将数据显示出来?多谢!!
 
你的程序我看过,非常好!可如何从N个数中选7,程序又该作如何改动?再有,排列完后,又该如何将数据显示出来?多谢!!
 
没有找到啊!
 
递归函数组合用了24分钟,是用在哪呢?是算号,还是写数据库啊?
 
是算号用了24分钟。sq68686
 
自建索引 直接定位
 
我也在www.cp188.com网站上下载奇翔彩票,它的组号确实非常快.30个号码选7共200多万组,只用了十秒左右就完成了,
我也想问奇翔是用什么算法组号的,为什么这么快?
期待中!!!
 
procedure TForm1.Button1Click(Sender: TObject);
var
k, i1, i2, i3, i4, i5, i6, i7, v: integer;
FLine: array [1..30] of byte;
FOut: array [1..7] of byte;
begin
for k := 1 to 30do
FLine[k] := k;
k := GetTickCount;
v := 0;
for i1 := 1 to 30 - 6do
begin
FOut[1] := FLine[i1];
for i2 := i1 + 1 to 30 - 5do
begin
FOut[2] := FLine[i2];
for i3 := i2 + 1 to 30 - 4do
begin
FOut[3] := FLine[i3];
for i4 := i3 + 1 to 30 - 3do
begin
FOut[4] := FLine[i4];
for i5 := i4 + 1 to 30 - 2do
begin
FOut[5] := FLine[i5];
for i6 := i5 + 1 to 30 - 1do
begin
FOut[6] := FLine[i6];
for i7 := i6 + 1 to 30do
begin
FOut[7] := FLine[i7];
inc(v);
end;
end;
end;
end;
end;
end;
end;

TButton(Sender).Caption := Format('%6d ms',[integer(GetTickCount) - k]);
Caption := IntToStr(v);
end;
 
如何从N个数中选7,程序又该作何改动呢?请jeffrey_s明示.多谢!!
 
procedure TForm1.Button1Click(Sender: TObject);
var
k, i1, i2, i3, i4, i5, i6, i7, v, Count: integer;
FLine: array of String[2];
FOut: array [1..7] of String[2];
FLines: TStrings;
Str: String;
begin
Count := Memo1.Lines.Count;
SetLength(FLine, Count + 1);
for k := 1 to Countdo
FLine[k] := Memo1.Lines[k - 1];
k := GetTickCount;
v := 0;
FLines := TStringList.Create;
try
for i1 := 1 to Count - 6do
begin
FOut[1] := FLine[i1];
for i2 := i1 + 1 to Count - 5do
begin
FOut[2] := FLine[i2];
for i3 := i2 + 1 to Count - 4do
begin
FOut[3] := FLine[i3];
for i4 := i3 + 1 to Count - 3do
begin
FOut[4] := FLine[i4];
for i5 := i4 + 1 to Count - 2do
begin
FOut[5] := FLine[i5];
for i6 := i5 + 1 to Count - 1do
begin
FOut[6] := FLine[i6];
for i7 := i6 + 1 to Countdo
begin
FOut[7] := FLine[i7];
inc(v);
if v < 500 then
begin
str := Format('%3s%3s%3s%3s%3s%3s%3s',
[FOut[1], FOut[2], FOut[3], FOut[4], FOut[5], FOut[6],
FOut[7]]);
FLines.Add(Str);
end;
end;
end;
end;
end;
end;
end;
end;
Memo2.Lines.Assign(FLines);
finally
FLines.Free;
end;

TButton(Sender).Caption := Format('%6d ms',[integer(GetTickCount) - k]);
Caption := IntToStr(v);
end;
 
http://www.delphibbs.com/keylife/iblog_show.asp?xid=13549
 
接受答案了.
 
不会吧。。。一分都没有
 
对不起,当时点错了,把分错点给app2001了,真对不起!!!以后我会加倍补偿的!!1
 

Similar threads

S
回复
0
查看
958
SUNSTONE的Delphi笔记
S
S
回复
0
查看
779
SUNSTONE的Delphi笔记
S
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部