|
两个问题:
1、最小怎么判定?
2、0-100,包括0和100吗?
- Sub Best()
- Dim A, B, C, D As Integer, ZZ As Double, i%
- If TypeName([F3].Value) = "Error" Then [F3] = 1000
- For i = 1 To 1000
- Do Until A + B + C + D = 100
- Randomize
- A = Int(Rnd(Time()) * 101)
- B = Int(Rnd(Time()) * 101)
- C = Int(Rnd(Time()) * 101)
- D = Int(Rnd(Time()) * 101)
- Loop
- ZZ = ([B3] * [D3] * A + [B4] * [D4] * B + [B5] * [D5] * C + [B6] * [D6] * D) / 100
- On Error Resume Next
- If ZZ < [F3] Then
- [E3] = A: [E4] = B: [E5] = C: [E6] = D
- [F3] = ZZ
- End If
- Next
- End Sub
复制代码
测试一下吧,按我的理解:手动到最小,0-100包括0和100,即最大100,最小0.
|
|