作者nathanwu (孤苦無依肥胖煙酒生)
看板Visual_Basic
標題[VB6 ]請問指派問題
時間Tue Nov 22 22:02:37 2005
指派問題
作者: N (---.ie.nthu.edu.tw)
日期: 11-22-05 21:01
請問如果今天我將1~n的數字以四個一組
列出所有的組合出來
然後指派一組數字後
讓未被指派的數字再去計算並列出所有的組合出來
然後繼續指派下去直到所有數字都被指派完畢
我是已經將組合的程式寫出如下
但是沒辦法做二次選取
能否請各位大大指教一下
感激不盡
Private Sub runCmd_Click()
Cls
nob = Val(nob.Text)
'---generate data and print---------------------------
t = 0
If nob < 4 Then
Print "please insert a number >= 4"
Else
For a = 1 To nob - 3
For b = 2 To nob - 2
For c = 3 To nob - 1
For d = 4 To nob
If a < b And b < c And c < d Then
t = t + 1
ary(t, 1) = a
ary(t, 2) = b
ary(t, 3) = c
ary(t, 4) = d
List1.AddItem "第" & t & "種排列:" & ary(t, 1) & ary(t, 2) & ary(t, 3) & ary(t, 4)
End If
Next d
Next c
Next b
Next a
DoEvents
End If
End Sub
______________________________以下是選取的程式碼______________
Private Sub Command2_Click()
Cls
x = Text1.Text
k = 1
List2.AddItem "第" & k & "個工作站內容:" & ary(x, 1) & ary(x, 2) & ary(x, 3) & ary(x, 4)
End Sub
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.54.243