我想了一下,编了个满足你要求的,并加上详细的注解,运行的结果是对的,如图,我运行了三次,每次编排的橘胡结果都不一样。
Private Sub Command1_Click()
List1.Clear
Randomize '随机数初始化,这个非常重顷伍逗要!
Dim XX(1 To 8) As Integer, YY(1 To 8, 1 To 6) As Integer
For i = 1 To 48 '对人进行循环
Do While (Z = False) '只要此人未分配,就一直循环
A = Rnd(1)
B = Int(7 * A + 1 + 0.5) '先把i分配到B组,B的值肯定在1,2,3,。雀卖。。8之间
If XX(B) < 6 Then '当B组的人数不足6人时,就分给B组
XX(B) = XX(B) + 1 '这个组的人数+1
YY(B, XX(B)) = i
Z = True '此人已分配
End If
Loop
Next i
For i = 1 To 8
List1.AddItem "第" & Str(i) & "组:"
For j = 1 To 6
List1.AddItem YY(i, j)
Next j
Next i
End Sub
Private Sub Command1_Click()Dim x As Integer, s As Integer, i As Integer
Randomize
Me.Cls
x = Int(Rnd * 34) + 1
s = 34
Print "总人数" s "人"
Print "分成" x "组"
For i 耐答咐= 1 To x
Print "第" i "组" s \ (x 举锋- i + 1) "人"
s = s - s 昌纯\ (x - i + 1)
Next
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)