|
本帖最后由 爱疯 于 2013-9-4 11:31 编辑
Sub test()
Dim A(), B(), d, i, s1, s2, s3, s
A = Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
B = Array("+", "-", "*", "/")
Set d = CreateObject("scripting.dictionary")
Do
9
s1 = Int(UBound(A) * Rnd): s1 = A(s1)
s2 = Int(UBound(B) * Rnd): s2 = B(s2)
s3 = Int(UBound(A) * Rnd): s3 = A(s3)
s = s1 & s2 & s3 & "="
If InStr(s, "-") And s1 < s3 Then GoTo 9
i = i + 1: d(s) = i
Loop Until d.Count = 200
[a1].Resize(d.Count) = Application.Transpose(d.keys)
End Sub
优点
1)简单
缺点
2)回避了题目关于重复的条件,也就失去本题的学习意义。
2)用了goto
3)可能在特殊条件下慢死。
|
|