本帖最后由 mactsmh 于 2010-11-30 11:12:09 编辑

解决方案 »

  1.   

    增加说明:有K个数据的话,排列次数e=k/2(k为偶数时),e=k/2(k为奇数时)。
      

  2.   

    哦,定一个计数器 count=1
    查找到 VBcrlf  count就加1,记录下 VBcrlf 字符位置
    if count mod e =0 then
       删除这个VBcrlf 字符……
      

  3.   

    const MAX = 100000&
    dim d(0 to MAX) as long
    dim s(0 to MAX) as long
    dim n as long
    dim y as long
    dim x as long
    dim e as long
    dim i as long
    n=21
    d( 0)=429
    d( 1)=654
    d( 2)=743
    d( 3)=1049
    d( 4)=568
    d( 5)=448
    d( 6)=305
    d( 7)=668
    d( 8)=226
    d( 9)=845
    d(10)=523
    d(11)=1214
    d(12)=590
    d(13)=87
    d(14)=589
    d(15)=436
    d(16)=401
    d(17)=216
    d(18)=573
    d(19)=409
    d(20)=921
    for e=2 to n
        debug.print "e=";e
        for y=0 to n\e
            for x=0 to e-1
                i=y*n\e+x
                debug.print d(i);
            next
            debug.print
        next
        debug.print "total ";
        for x=0 to e-1
            s(x)=0
            for y=0 to n\e
                i=y*n\e+x
                s(x)=s(x)+d(i)
            next
            debug.print s(i);
        next
        debug.print
    next
      

  4.   

    两个i=y*n\e+x
    后面都要加一句
    if i>=n then exit for
      

  5.   

    最终调试通过的代码:
    Option Explicit
    Const MAX = 100000
    Dim d(0 To MAX) As Long
    Dim s(0 To MAX) As Long
    Dim n As Long
    Dim y As Long
    Dim x As Long
    Dim e As Long
    Dim i As Long
    Private Sub Command1_Click()
    n = 21
    d(0) = 429
    d(1) = 654
    d(2) = 743
    d(3) = 1049
    d(4) = 568
    d(5) = 448
    d(6) = 305
    d(7) = 668
    d(8) = 226
    d(9) = 845
    d(10) = 523
    d(11) = 1214
    d(12) = 590
    d(13) = 87
    d(14) = 589
    d(15) = 436
    d(16) = 401
    d(17) = 216
    d(18) = 573
    d(19) = 409
    d(20) = 921
    For e = 2 To n
        Debug.Print "e="; e
        For y = 0 To n \ e
            For x = 0 To e - 1
                i = y * e + x
                If i >= n Then Exit For
                Debug.Print d(i);
            Next
            Debug.Print
        Next
        Debug.Print "total ";
        For x = 0 To e - 1
            s(x) = 0
            For y = 0 To n \ e
                i = y * e + x
                If i >= n Then Exit For
                s(x) = s(x) + d(i)
            Next
            Debug.Print s(x);
        Next
        Debug.Print
    Next
    End Sub