欢迎光临...问题是这个样子的,有一个3码数据:如zhsg(1) ="4 2 7" ,想以4,2,7为[定位]依据,转换成6码的数据,如假设4,2,7为第1,2,3位的定位尾号,则可转换成以下620个6码数据:04 12 17 18 19 20 
04 12 17 18 19 21 
04 12 17 18 19 22 
04 12 17 18 19 23 
04 12 17 18 19 24 
04 12 17 18 19 25 
04 12 17 18 19 26 
04 12 17 18 19 27 
04 12 17 18 19 28 
04 12 17 18 19 29 
04 12 17 18 19 30 
... 
14 22 27 31 32 33 即
第1位(04,14,24) mod 10=4 (第1位尾号=4)
第2位(02,12,22) mod 10=2 (第2位尾号=2)
第3位(07,17,27) mod 10=7 (第3位尾号=7)我的“超慢”程序:
Sub doubq1()Dim filenum  As IntegerDim i As Integer, j As Integer, k As Integer, l As Integer, m As Integer, n As Integer, p As IntegerDim index As LongDim zhhm(1 To 10000) As String   '符合条件的数组变量dim zhsg(1 to 147) as stringDim tp As Integer, lp As Integerdim arr(1 to 147,1 to 3)dim splitsDim sorfnum(1 To 33) As String
For i = 1 To 33  sorfnum(i) = Format(i, "00")
  
Next i
zhsg(1) ="4 2 7"
zhsg(2) ="1 7 0"
zhsg(3) ="1 9 0"
zhsg(4) ="6 7 8"
zhsg(5) ="1 4 3"
zhsg(6) ="1 7 7"
zhsg(7) ="2 4 1"
zhsg(8) ="3 7 1"
zhsg(9) ="1 3 5"
zhsg(10) ="4 7 8"
zhsg(11) ="5 2 4"
zhsg(12) ="2 5 6"
zhsg(13) ="5 0 1"
zhsg(14) ="1 2 9"
zhsg(15) ="5 9 1"
zhsg(16) ="3 0 4"
zhsg(17) ="1 8 4"
zhsg(18) ="1 3 1"
zhsg(19) ="7 8 0"
zhsg(20) ="4 0 4"
zhsg(21) ="1 5 9"
zhsg(22) ="1 2 3"
zhsg(23) ="9 3 0"
zhsg(24) ="1 7 9"
zhsg(25) ="3 6 9"
zhsg(26) ="2 5 8"
zhsg(27) ="1 4 8"
zhsg(28) ="2 7 3"
zhsg(29) ="2 8 6"
zhsg(30) ="2 3 7"
zhsg(31) ="3 4 1"
zhsg(32) ="1 6 7"
zhsg(33) ="0 6 8"
zhsg(34) ="7 7 9"
zhsg(35) ="8 0 7"
zhsg(36) ="6 0 3"
zhsg(37) ="4 9 0"
zhsg(38) ="2 6 7"
zhsg(39) ="1 2 8"
zhsg(40) ="7 5 6"
zhsg(41) ="1 7 8"
zhsg(42) ="8 9 1"
zhsg(43) ="1 2 4"
zhsg(44) ="6 7 9"
zhsg(45) ="2 3 9"
zhsg(46) ="1 2 4"
zhsg(47) ="2 3 4"
zhsg(48) ="9 1 4"
zhsg(49) ="6 8 9"
zhsg(50) ="1 0 1"
zhsg(51) ="5 1 3"
zhsg(52) ="1 8 1"
zhsg(53) ="4 7 1"
zhsg(54) ="3 5 1"
zhsg(55) ="3 6 9"
zhsg(56) ="1 2 5"
zhsg(57) ="7 0 3"
zhsg(58) ="4 5 8"
zhsg(59) ="3 4 7"
zhsg(60) ="5 3 0"
zhsg(61) ="1 6 7"
zhsg(62) ="2 8 1"
zhsg(63) ="2 1 5"
zhsg(64) ="0 2 1"
zhsg(65) ="3 8 6"
zhsg(66) ="8 5 8"
zhsg(67) ="2 7 3"
zhsg(68) ="5 6 5"
zhsg(69) ="7 8 1"
zhsg(70) ="3 5 3"
zhsg(71) ="8 9 0"
zhsg(72) ="4 5 0"
zhsg(73) ="7 3 4"
zhsg(74) ="3 8 0"
zhsg(75) ="3 5 1"
zhsg(76) ="3 0 4"
zhsg(77) ="4 6 7"
zhsg(78) ="1 4 8"
zhsg(79) ="3 8 1"
zhsg(80) ="0 3 8"
zhsg(81) ="1 3 7"
zhsg(82) ="2 0 9"
zhsg(83) ="4 7 0"
zhsg(84) ="1 8 0"
zhsg(85) ="9 3 4"
zhsg(86) ="1 4 8"
zhsg(87) ="1 4 0"
zhsg(88) ="5 9 0"
zhsg(89) ="9 2 7"
zhsg(90) ="1 4 2"
zhsg(91) ="0 9 0"
zhsg(92) ="3 2 3"
zhsg(93) ="5 0 1"
zhsg(94) ="6 8 9"
zhsg(95) ="2 9 4"
zhsg(96) ="3 9 2"
zhsg(97) ="2 3 5"
zhsg(98) ="7 1 7"
zhsg(99) ="7 9 0"
zhsg(100) ="0 5 3"
zhsg(101) ="1 8 2"
zhsg(102) ="8 3 4"
zhsg(103) ="6 8 0"
zhsg(104) ="4 9 0"
zhsg(105) ="1 6 8"
zhsg(106) ="9 3 5"
zhsg(107) ="8 0 3"
zhsg(108) ="1 6 9"
zhsg(109) ="2 6 0"
zhsg(110) ="1 3 5"
zhsg(111) ="1 3 7"
zhsg(112) ="3 4 7"
zhsg(113) ="6 9 8"
zhsg(114) ="7 8 8"
zhsg(115) ="7 3 6"
zhsg(116) ="3 1 4"
zhsg(117) ="1 7 8"
zhsg(118) ="6 9 0"
zhsg(119) ="9 2 5"
zhsg(120) ="1 4 8"
zhsg(121) ="5 9 0"
zhsg(122) ="2 4 5"
zhsg(123) ="7 5 7"
zhsg(124) ="1 9 2"
zhsg(125) ="2 7 2"
zhsg(126) ="8 0 1"
zhsg(127) ="9 1 3"
zhsg(128) ="2 3 6"
zhsg(129) ="7 8 6"
zhsg(130) ="3 9 1"
zhsg(131) ="4 8 9"
zhsg(132) ="1 5 6"
zhsg(133) ="2 6 0"
zhsg(134) ="1 3 6"
zhsg(135) ="6 1 2"
zhsg(136) ="4 6 9"
zhsg(137) ="2 6 4"
zhsg(138) ="8 0 2"
zhsg(139) ="0 5 9"
zhsg(140) ="5 9 4"
zhsg(141) ="1 7 0"
zhsg(142) ="6 2 4"
zhsg(143) ="1 3 4"
zhsg(144) ="4 9 2"
zhsg(145) ="2 4 1"
zhsg(146) ="1 5 9"
zhsg(147) ="4 0 6"'字串变数组for tp=1 to 147 splits = Split(zhsg(tp), " ")
     
  For i = 0 To UBound(splits)
       
    arr(tp, i + 1) = splits(i)
         
  Next inext tp
'判断组合类型1For tp = 1 To 147index = 1 For i = 1 To 28
 
   For j = i + 1 To 29
   
     For k = j + 1 To 30
     
       For l = k + 1 To 31
       
         For n = l + 1 To 32
         
           For p = n + 1 To 33
           
            If i Mod 10 = arr(tp, 1) And j Mod 10 = arr(tp, 2) And k Mod 10 = arr(tp, 3) Then
            
              zhhm(index) = sorfnum(i) & " " & sorfnum(j) & " " & sorfnum(k) & " " & sorfnum(l) & " " & sorfnum(n) & " " & sorfnum(p)
              
              index = index + 1
              
            End If
           
          Next
           
         Next
         
       Next
      
     Next
    
   Next
   
 Next
  '写入文本
       
   filenum = FreeFile
 
   Open app.path & "\转换结果.txt" For Append As #filenum
   
  
   For i= 1 To index - 1
     
   Print #filenum, zhhm(i)
   
   Next i
   
   Close filenum
   
    
Next tp
End Sub在我的机器上运算转换以上147个转换要41秒,而实际要转换的有近6千个,时间近似为:6000/147*41=1673.47秒,我晕...请各位朋友伸出援助之手,拉小弟一把,小弟这厢有礼了,呵呵...

解决方案 »

  1.   

    我也没能搞明白,后面那仨数是干什么的?
    既然是mod 10,那直接加10不就得了。
      

  2.   

    其实就是双色球的定位转换以第1种转换例:zhsg(1) ="4 2 7"这里的4,2,7为欲求的6码组合的[前3位]的尾号,理解为:第1位尾号为4,第2位尾号为2,第3位尾号为7这样,第1位可出的数字尾为:4 ,对应的数据为:04 14 24
         第2位可出的数字尾为:2, 对应的数据为:02 12 22
         第3位可出的数字尾为:7, 对应的数据为:07 17 27[后3位]是在前3位已定的基础上,按大小顺序组合如第1位:取04,那么第2位[按从小到大排序],且只能取尾号为2(02 12 22)中的一个,所以只能取12或22 第3位类推取17或27则组合为:  04 12 17
               04 12 27
               04 22 27再以第1个组合:04 12 17为例:前3位组合为:04 12 17 后3位同样按从小到大排序(在4-33中取数),则取18 19 20即为转换结果的第1个数据:04 12 17 18 19 20  下面的是以第1,2,3位的尾号组合为4, 2,7 的所有6码组合620注:04 12 17 18 19 20 
    04 12 17 18 19 21 
    04 12 17 18 19 22 依次类推:zhsg(2) ="1 7 0" 表示 第1,2,3位的尾号组合是1 ,7,0 的所有6码组合....01 07 10 11 12 13 
    01 07 10 11 12 14 
    01 07 10 11 12 15 
    01 07 10 11 12 16 
    01 07 10 11 12 17 
    01 07 10 11 12 18 
    01 07 10 11 12 19 
    01 07 10 11 12 20 
    01 07 10 11 12 21 
    01 07 10 11 12 22 
    01 07 10 11 12 23 
    01 07 10 11 12 24 
    .....计2635注估计你没玩过双色球,谢谢参与...
      

  3.   

    其实就是双色球的定位转换以第1种转换例:zhsg(1) ="4 2 7"这里的4,2,7为欲求的6码组合的[前3位]的尾号,理解为:第1位尾号为4,第2位尾号为2,第3位尾号为7这样,第1位可出的数字尾为:4 ,对应的数据为:04 14 24
         第2位可出的数字尾为:2, 对应的数据为:02 12 22
         第3位可出的数字尾为:7, 对应的数据为:07 17 27[后3位]是在前3位已定的基础上,按大小顺序组合如第1位:取04,那么第2位[按从小到大排序],且只能取尾号为2(02 12 22)中的一个,所以只能取12或22 第3位类推取17或27则组合为:  04 12 17
               04 12 27
               04 22 27再以第1个组合:04 12 17为例:前3位组合为:04 12 17 后3位同样按从小到大排序(在4-33中取数),则取18 19 20即为转换结果的第1个数据:04 12 17 18 19 20  下面的是以第1,2,3位的尾号组合为4, 2,7 的所有6码组合620注:04 12 17 18 19 20 
    04 12 17 18 19 21 
    04 12 17 18 19 22 依次类推:zhsg(2) ="1 7 0" 表示 第1,2,3位的尾号组合是1 ,7,0 的所有6码组合....01 07 10 11 12 13 
    01 07 10 11 12 14 
    01 07 10 11 12 15 
    01 07 10 11 12 16 
    01 07 10 11 12 17 
    01 07 10 11 12 18 
    01 07 10 11 12 19 
    01 07 10 11 12 20 
    01 07 10 11 12 21 
    01 07 10 11 12 22 
    01 07 10 11 12 23 
    01 07 10 11 12 24 
    .....计2635注估计你没玩过双色球,谢谢你的参与...
      

  4.   

    大概明白了。既然是mod 10,那就直接加10得了,加完10比下一个,小了也加10,一直到出限。你这样六层循环肯定非常慢。
      

  5.   

    大概明白了。 既然是mod 10,那就直接加10得了,加完10比下一个,小了也加10,一直到出限。你这样六层循环肯定非常慢。问题是后面的3位并不能以10为步长的,要步长为1循环的04 12 17 18 19 20 
    04 12 17 18 19 21 
    04 12 17 18 19 22 
    04 12 17 18 19 23 
    04 12 17 18 19 24 
    04 12 17 18 19 25 
    04 12 17 18 19 26 
    04 12 17 18 19 27 
    04 12 17 18 19 28 
    04 12 17 18 19 29 
    04 12 17 18 19 30 
    04 12 17 18 19 31 
    04 12 17 18 19 32 
    04 12 17 18 19 33 在前3位定为:04 12 17的基础上,后3位是 
    18 19 20 
    18 19 21
    18 19 22
    ...
    18 32 33 
    其它类推 
      

  6.   

    用这段代码试试:
    Sub doubq1()Dim filenum  As Integer
    Dim i As Integer, j As Integer, k As Integer, l As Integer  ', m As Integer, n As Integer, p As Integer
    Dim index As Long
    Dim zhhm(1 To 10000) As String   '符合条件的数组变量
    Dim zhsg(1 To 147) As String
    Dim tp As Integer, lp As Integer
    Dim arr(1 To 147, 1 To 3)
    'Dim splits
    Dim splits() As String      '(指定类型)
    Dim sorfnum(1 To 33) As String
    '(我添加的变量)
    Dim lNumAs&, lNumBs&, lNumCs&, lFlag&, strAnte$
    Dim lNumAc&, lNumBc&, lNumCc&For i = 1 To 33
        'sorfnum(i) = Format(i, "00")
        sorfnum(i) = Format(i, " 00")   '(这里加上一个空格)
    Next izhsg(1) = "4 2 7"
    zhsg(2) = "1 7 0"
    zhsg(3) = "1 9 0"
    zhsg(4) = "6 7 8"
    zhsg(5) = "1 4 3"
    zhsg(6) = "1 7 7"
    zhsg(7) = "2 4 1"
    zhsg(8) = "3 7 1"
    zhsg(9) = "1 3 5"
    zhsg(10) = "4 7 8"
    zhsg(11) = "5 2 4"
    zhsg(12) = "2 5 6"
    zhsg(13) = "5 0 1"
    zhsg(14) = "1 2 9"
    zhsg(15) = "5 9 1"
    zhsg(16) = "3 0 4"
    zhsg(17) = "1 8 4"
    zhsg(18) = "1 3 1"
    zhsg(19) = "7 8 0"
    zhsg(20) = "4 0 4"
    zhsg(21) = "1 5 9"
    zhsg(22) = "1 2 3"
    zhsg(23) = "9 3 0"
    zhsg(24) = "1 7 9"
    zhsg(25) = "3 6 9"
    zhsg(26) = "2 5 8"
    zhsg(27) = "1 4 8"
    zhsg(28) = "2 7 3"
    zhsg(29) = "2 8 6"
    zhsg(30) = "2 3 7"
    zhsg(31) = "3 4 1"
    zhsg(32) = "1 6 7"
    zhsg(33) = "0 6 8"
    zhsg(34) = "7 7 9"
    zhsg(35) = "8 0 7"
    zhsg(36) = "6 0 3"
    zhsg(37) = "4 9 0"
    zhsg(38) = "2 6 7"
    zhsg(39) = "1 2 8"
    zhsg(40) = "7 5 6"
    zhsg(41) = "1 7 8"
    zhsg(42) = "8 9 1"
    zhsg(43) = "1 2 4"
    zhsg(44) = "6 7 9"
    zhsg(45) = "2 3 9"
    zhsg(46) = "1 2 4"
    zhsg(47) = "2 3 4"
    zhsg(48) = "9 1 4"
    zhsg(49) = "6 8 9"
    zhsg(50) = "1 0 1"
    zhsg(51) = "5 1 3"
    zhsg(52) = "1 8 1"
    zhsg(53) = "4 7 1"
    zhsg(54) = "3 5 1"
    zhsg(55) = "3 6 9"
    zhsg(56) = "1 2 5"
    zhsg(57) = "7 0 3"
    zhsg(58) = "4 5 8"
    zhsg(59) = "3 4 7"
    zhsg(60) = "5 3 0"
    zhsg(61) = "1 6 7"
    zhsg(62) = "2 8 1"
    zhsg(63) = "2 1 5"
    zhsg(64) = "0 2 1"
    zhsg(65) = "3 8 6"
    zhsg(66) = "8 5 8"
    zhsg(67) = "2 7 3"
    zhsg(68) = "5 6 5"
    zhsg(69) = "7 8 1"
    zhsg(70) = "3 5 3"
    zhsg(71) = "8 9 0"
    zhsg(72) = "4 5 0"
    zhsg(73) = "7 3 4"
    zhsg(74) = "3 8 0"
    zhsg(75) = "3 5 1"
    zhsg(76) = "3 0 4"
    zhsg(77) = "4 6 7"
    zhsg(78) = "1 4 8"
    zhsg(79) = "3 8 1"
    zhsg(80) = "0 3 8"
    zhsg(81) = "1 3 7"
    zhsg(82) = "2 0 9"
    zhsg(83) = "4 7 0"
    zhsg(84) = "1 8 0"
    zhsg(85) = "9 3 4"
    zhsg(86) = "1 4 8"
    zhsg(87) = "1 4 0"
    zhsg(88) = "5 9 0"
    zhsg(89) = "9 2 7"
    zhsg(90) = "1 4 2"
    zhsg(91) = "0 9 0"
    zhsg(92) = "3 2 3"
    zhsg(93) = "5 0 1"
    zhsg(94) = "6 8 9"
    zhsg(95) = "2 9 4"
    zhsg(96) = "3 9 2"
    zhsg(97) = "2 3 5"
    zhsg(98) = "7 1 7"
    zhsg(99) = "7 9 0"
    zhsg(100) = "0 5 3"
    zhsg(101) = "1 8 2"
    zhsg(102) = "8 3 4"
    zhsg(103) = "6 8 0"
    zhsg(104) = "4 9 0"
    zhsg(105) = "1 6 8"
    zhsg(106) = "9 3 5"
    zhsg(107) = "8 0 3"
    zhsg(108) = "1 6 9"
    zhsg(109) = "2 6 0"
    zhsg(110) = "1 3 5"
    zhsg(111) = "1 3 7"
    zhsg(112) = "3 4 7"
    zhsg(113) = "6 9 8"
    zhsg(114) = "7 8 8"
    zhsg(115) = "7 3 6"
    zhsg(116) = "3 1 4"
    zhsg(117) = "1 7 8"
    zhsg(118) = "6 9 0"
    zhsg(119) = "9 2 5"
    zhsg(120) = "1 4 8"
    zhsg(121) = "5 9 0"
    zhsg(122) = "2 4 5"
    zhsg(123) = "7 5 7"
    zhsg(124) = "1 9 2"
    zhsg(125) = "2 7 2"
    zhsg(126) = "8 0 1"
    zhsg(127) = "9 1 3"
    zhsg(128) = "2 3 6"
    zhsg(129) = "7 8 6"
    zhsg(130) = "3 9 1"
    zhsg(131) = "4 8 9"
    zhsg(132) = "1 5 6"
    zhsg(133) = "2 6 0"
    zhsg(134) = "1 3 6"
    zhsg(135) = "6 1 2"
    zhsg(136) = "4 6 9"
    zhsg(137) = "2 6 4"
    zhsg(138) = "8 0 2"
    zhsg(139) = "0 5 9"
    zhsg(140) = "5 9 4"
    zhsg(141) = "1 7 0"
    zhsg(142) = "6 2 4"
    zhsg(143) = "1 3 4"
    zhsg(144) = "4 9 2"
    zhsg(145) = "2 4 1"
    zhsg(146) = "1 5 9"
    zhsg(147) = "4 0 6"'字串变数组
    For tp = 1 To 147
        splits = Split(zhsg(tp), " ")
    '    For i = 0 To UBound(splits)
    '        arr(tp, i + 1) = splits(i)
    '    Next i
        index = 1
        lNumAs = Val(splits(0))
        lNumBs = Val(splits(1))
        lNumCs = Val(splits(2))
        If (lNumAs = 0) Then lNumAs = 10&
        If (lNumBs = 0) Then lNumBs = 10&
        If (lNumCs = 0) Then lNumCs = 10&
        For i = 0 To 2          ' 0 to UBound(splits)
            lNumAc = lNumAs
            lNumBc = lNumBs
            lNumCc = lNumCs
            Do
                While (lNumBc < lNumAc): lNumBc = lNumBc + 10&: Wend
                While (lNumCc < lNumBc): lNumCc = lNumCc + 10&: Wend
                If (lNumBc > 29) Then
                    lFlag = 7
                    Exit Do
                End If
                If (lNumCc > 30) Then
                    lFlag = 1
                Else
                    lFlag = 3
                    strAnte = LTrim$(sorfnum(lNumAc) & sorfnum(lNumBc) & sorfnum(lNumCc))
                    For j = lNumCc + 1 To 31
                        For k = j + 1 To 32
                            For l = k + 1 To 33
                                zhhm(index) = strAnte & sorfnum(j) & sorfnum(k) & sorfnum(l)
                                index = index + 1
                            Next
                        Next
                    Next
                End If
                lNumCc = lNumCc + 10&
                If (lFlag = 1) Then
                    lNumBc = lNumBc + 10&
                    lNumCc = lNumCs
                End If
            Loop While (True)
            lNumAs = lNumAs + 10&
            lNumBs = lNumBs + 10&
            lNumCs = lNumCs + 10&
        Next
        '写入文本
        filenum = FreeFile
        Open App.Path & "\转换结果.txt" For Append As #filenum
        For i = 1 To index - 1
            Print #filenum, zhhm(i)
        Next i
        Close filenum
    Next tp'判断组合类型1
    'For tp = 1 To 147
    'index = 1
    ' For i = 1 To 28
    '   For j = i + 1 To 29
    '     For k = j + 1 To 30
    '       For l = k + 1 To 31
    '         For n = l + 1 To 32
    '           For p = n + 1 To 33
    '            If i Mod 10 = arr(tp, 1) And j Mod 10 = arr(tp, 2) And k Mod 10 = arr(tp, 3) Then
    '              zhhm(index) = sorfnum(i) & " " & sorfnum(j) & " " & sorfnum(k) & " " & sorfnum(l) & " " & sorfnum(n) & " " & sorfnum(p)
    '              index = index + 1
    '            End If
    '          Next
    '         Next
    '       Next
    '     Next
    '   Next
    ' Next
    '
    ' '写入文本
    '   filenum = FreeFile
    '   Open App.Path & "\转换结果.txt" For Append As #filenum
    '   For i = 1 To index - 1
    '   Print #filenum, zhhm(i)
    '   Next i
    '   Close filenum
    '
    'Next tpEnd Sub
      

  7.   


    快得不是一点半点呀,这是脱胎换骨! ^_^向乐于助人的高手chen8013致敬!!!
      

  8.   

    写了个进位法,效率不知怎么样,算是一种算法吧
    午间代码赶的比较急,有点乱,如果可以自己整理
    Option Explicit'进位
    Sub Carry(a() As Byte, ByVal cValue As Long, ByVal Idx As Long)
        '逢cValue进位,Idx数组a的最大下标
        Do
            a(Idx) = a(Idx) + 1
            If a(Idx) > cValue Then
                a(Idx) = 0
                Idx = Idx - 1
            Else
                Exit Do
            End If
        Loop
    End Sub'验证重复
    Function RepeatNum(a() As Byte, ByVal cValue As Long, ByVal Idx As Long) As Boolean
        Dim i As Long
        Dim b() As Boolean
        ReDim b(cValue)
        For i = 0 To Idx
            If b(a(i)) = False Then
                b(a(i)) = True
            Else
                RepeatNum = False  '有重复的Idx就退出
                Exit Function
            End If
        Next
        RepeatNum = True
    End Function'初始化基本数组和进位数组
    Sub InitialArray(ByVal s As String, p() As String, Sta() As Byte)
        Dim i As Long
        Dim n As Long
        p = Split(s, Chr(32))
        n = p(0)
        For i = 1 To UBound(p)
            If p(i) < n Then
                p(i) = p(i) + 10
            End If
            n = p(i)
        Next
        For i = 0 To 2
            Sta(i) = n + 1
            n = n + 1
        Next
    End Sub'输出结果
    Sub PrintResult(r() As String, p() As String, s() As Byte)
        Dim i As Long
        For i = 0 To 2
            r(i) = p(i)
        Next
        For i = 0 To 2
            r(i + 3) = s(i)
        Next
        'Debug.Print Join(r)
    End SubPrivate Sub Command1_Click()    Dim Par() As String      '基本号
        Dim Sta(2) As Byte       '进位数组
        Dim Result(5) As String  '结果
        Dim s As String
        Dim i As Long
        
        s = "4 2 7"
        InitialArray s, Par, Sta
        PrintResult Result, Par, Sta  '输出第一个结果
        Do
            Carry Sta, 33, 2
            If RepeatNum(Sta, 33, 2) Then
                PrintResult Result, Par, Sta
            End If
        Loop Until Sta(0) = 31 And Sta(1) = 32 And Sta(2) = 33
        MsgBox "OK"
    End Sub
      

  9.   

    晕死没提交成?
    Option Explicit'进位
    Sub Carry(a() As Byte, ByVal cValue As Long, ByVal Idx As Long)
        '逢cValue进位,Idx数组a的最大下标
        Do
            a(Idx) = a(Idx) + 1
            If a(Idx) > cValue Then
                a(Idx) = 0
                Idx = Idx - 1
            Else
                Exit Do
            End If
        Loop
    End Sub'验证重复
    Function RepeatNum(a() As Byte, ByVal cValue As Long, ByVal Idx As Long) As Boolean
        Dim i As Long
        Dim b() As Boolean
        ReDim b(cValue)
        For i = 0 To Idx
            If b(a(i)) = False Then
                b(a(i)) = True
            Else
                RepeatNum = False  '有重复的Idx就退出
                Exit Function
            End If
        Next
        RepeatNum = True
    End Function'初始化基本数组和进位数组
    Sub InitialArray(ByVal s As String, p() As String, Sta() As Byte)
        Dim i As Long
        Dim n As Long
        p = Split(s, Chr(32))
        n = p(0)
        For i = 1 To UBound(p)
            If p(i) < n Then
                p(i) = p(i) + 10
            End If
            n = p(i)
        Next
        For i = 0 To 2
            Sta(i) = n + 1
            n = n + 1
        Next
    End Sub'输出结果
    Sub PrintResult(r() As String, p() As String, s() As Byte)
        Dim i As Long
        For i = 0 To 2
            r(i) = p(i)
        Next
        For i = 0 To 2
            r(i + 3) = s(i)
        Next
        'Debug.Print Join(r)
    End SubPrivate Sub Command1_Click()    Dim Par() As String
        Dim Sta(2) As Byte
        Dim Result(5) As String
        Dim s As String
        Dim i As Long
        
        s = "4 2 7"
        InitialArray s, Par, Sta
        PrintResult Result, Par, Sta  '输出第一个结果
        Do
            Carry Sta, 33, 2
            If RepeatNum(Sta, 33, 2) Then
                PrintResult Result, Par, Sta
            End If
        Loop Until Sta(0) = 31 And Sta(1) = 32 And Sta(2) = 33
        MsgBox "OK"
    End Sub
      

  10.   


    TO chen8013:
    这还是“小事一桩”?我搞了三天呀 !
    同是编程序,差距咋就这么大呢?
    多亏俺不是专业搞程序,靠程序吃饭的,否则碰上你,连粥都喝不上了,呵呵~
      

  11.   


    TO VBMAN2003:
       似乎第1次的代码没提交上?
       这个代码好象不全,看得我在云雾里...   不管怎样,感谢你的支持,让我多了解了一种算法
        我再看看,很可能是我太莱了,没看懂 ^_^
      

  12.   


    TO VBMAN2003:
      
       感谢你的支持,让我多了解了一种算法,谢谢!
      

  13.   

    原来第1次给VBMAN2003的回复已经提交了,怎么显示没提交上?晕...