|
发表于 2020-3-14 19:30:02
|
显示全部楼层
给你写了个函数CreateArray, 并有例子:
Option Explicit
Private Sub CreateArray(ByVal M As Integer, ByRef ABuf)
ReDim ABuf(2 ^ M - 1, M - 1)
Dim iRow As Integer
Dim iCol As Integer
Dim iNum As Integer
For iRow = 0 To 2 ^ M - 1
iNum = iRow
For iCol = M - 1 To 0 Step -1
ABuf(iRow, iCol) = iNum Mod 2
iNum = iNum \ 2
Next iCol
Next iRow
End Sub
Private Sub Command1_Click()
Dim A() As Integer
Dim i As Integer
Dim j As Integer
Dim k As Integer
k = InputBox("输入M的值")
CreateArray k, A
For i = 0 To 2 ^ k - 1
For j = 0 To k - 1
Debug.Print A(i, j);
Next j
Debug.Print
Next i
End Sub
|
|