全组合需要12个小时才能算出45选6的全部组合。有没有办法改进一下运行时间呢。程序代码如下:注意是VFP的,我只会这个编程。
我用VFP设计了一个计算全组合的程序发给大家看看。帮忙改进一下。应为算了一下运行时间,全组合需要12个小时才能算出45选6的全部组合。有没有办法改进一下运行时间呢。程序代码如下:注意是VFP的,我只会这个编程。 CREAT TABLE ddd(x1 n,X2 N,x3 n,x4 n,x5 n,x6 n)
use ddd
x=45
dimension abs1(x)
for aa=1 to x
abs1(aa)=aa
endfor
dimension abs2(6)
for a=1 to x
for b=1 to x
if abs1(a)=abs1(b)
loop
endif
for c=1 to x
if abs1(a)=abs1(c) or abs1(b)=abs1(c)
loop
endif
for d=1 to x
if abs1(a)=abs1(d) or abs1(b)=abs1(d) or abs1(c)=abs1(d)
loop
endif
for e=1 to x
if abs1(a)=abs1(e) or abs1(b)=abs1(e) or abs1(c)=abs1(e) or abs1(d)=abs1(e)
loop
endif
for f=1 to x
if abs1(a)=abs1(f) or abs1(b)=abs1(f) or abs1(c)=abs1(f) or abs1(d)=abs1(f) or abs1(e)=abs1(f)
loop
endif
append blank
replace x1 with caa(1), x2 with caa(2), x3 with caa(3),x4 with caa(4),x5 with caa(5),x6 with caa(6)
endfor
endfor
endfor
endfor
endfor
endfor