|
'上午课程安排
kk = 2
For kk1 = 1 To k1
For kk2 = 1 To arr(kk1, 2)
kk = kk + 1
haha2:
ReDim xq2(1 To k2)
For i = 1 To k3
sj2 = ""
For j = 1 To k2
If xq2(j) < 4 Then sj2 = sj2 & "," & j
Next
If sj2 = "" Then Exit For Else sj2 = Mid(sj2, 2, 99)
sj3 = Split(sj2, ",")
m = UBound(sj3) + 1
ReDim sj(1 To m)
For ii = 1 To m
sj(ii) = sj3(ii - 1)
Next
'按周课时表 安排上午课
If crr(i, kk1 * 2) > 0 Then
If crr(i, kk1 * 2) > m Then
For jj = 1 To k2
Cells(kk, xq(jj) + 1).ClearContents
Cells(kk, xq(jj) + 2).ClearContents
Cells(kk, xq(jj) + 3).ClearContents
Cells(kk, xq(jj) + 4).ClearContents
Next
GoTo haha2
End If
n = crr(i, kk1 * 2)
ReDim jg$(1 To Application.Combin(m, n), 1 To 1)
k = 0
Call dgZH("", 0, 1)
rnd1 = Application.RandBetween(1, Application.Combin(m, n))
week = Split(jg(rnd1, 1), ",")
For j = 0 To UBound(week)
haha:
rnd2 = Application.RandBetween(1, 4)
If Cells(kk, xq(week(j)) + rnd2) = "" Then
Cells(kk, xq(week(j)) + rnd2) = crr(i, 1)
xq2(week(j)) = xq2(week(j)) + 1
Else
GoTo haha
End If
Next
End If
Next i
Next kk2
Next kk1 |
|