比尔盖茨客厅:用VB解决组合的算法,求教!

来源:百度文库 编辑:中科新闻网 时间:2024/05/10 10:16:59
A=[2,3,5,6];B=[1,2,4,5,6];C=[3,4,5,6];D=[1,2,3,4,6];E=[1,2,4,5,6];F=[1,2,3,5,6]。A~F中随机包含1个或6个数,求ABCDEF的N种组合,如213111,213112,213113,213115,213116,213121,213122,……666666,应该共有4*5*4*5*5*5=10000种组合!

dim a,b ,c ,d,e,f as integer
for a = 1 to len(a)
for b = 1 to len(b)
for c = 1 to len(c)
for d = 1 to len(d)
for e = 1 to len(e)
for f = 1 to len(f)
list1.additem mid(strA,a,1) & mid(strB,b,1) & mid(strC,b,1) & mid(strD,d,1) & mid(strE,e,1) & mid(strF,f,1)

next f
next e
next d
next c
next b
next a

不好意思。没VB测试。凭感觉写的代码。。

strA~ strF 6的字符串为你的