English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
所有分類

假設我有4個數字

A1 14
B1 15
C1 77
D1 41

請問我該怎麼讓它自己排列出所有的組合且不重複呢?...
不重複是指( 14,15,77,41.....跟 15,77,14,41)...是相同的...

且輸出的數字要在 A2.B2.C2.D2....就是不要在同一格裡那樣..

該怎麼做呢...謝謝

2007-01-12 04:00:51 · 1 個解答 · 發問者 呆呆傑 2 in 電腦與網際網路 程式設計

1 個解答


Private Sub CommandButton1_Click()
Dim A%(1 To 4), I%

For I = 1 To 4
A(I) = Int(Val(Cells(1, I)))
Next

Cal A, "", 1, 1
End Sub
Sub Cal(A%(), S$, P%, R%)
Dim I%, K$, D%, V$()

K = S
For I = P To UBound(A)
S = S & A(I) & " ": R = R + 1
V = Split(S)
For C = 0 To UBound(V) - 1
Cells(R, C + 1) = V(C)
Next
Cal A(), S, I + 1, R
S = K
Next
End Sub

2007-01-12 12:45:57 · answer #1 · answered by W.J.S. 7 · 0 0

fedest.com, questions and answers