4个回答
展开全部
Private Sub Command1_Click()
Dim a(3) As Integer, SumArr(), intSum As Integer, GCD(3) As Integer
SumArr = Array(10, 20, 30, 40)
For i = 0 To 9
For j = i + 1 To 9
For k = j + 1 To 9
For r = k + 1 To 9
For t = r + 1 To 9
List2.AddItem i & " " & j & " " & k & " " & r & " " & t
intSum = i + j + k + r + t
For w = LBound(a) To UBound(a)
If intSum = SumArr(w) Then
List1(w).AddItem i & " " & j & " " & k & " " & r & " " & t
a(w) = a(w) + 1
End If
Next w
Next t
Next r
Next k
Next j
Next i
For i = LBound(a) To UBound(a)
Label1(i) = List1(i).ListCount
GCD(i) = GreatestCommonDivisor(a(i), 252)
Label2(i).Caption = a(i) / GCD(i) & "/" & 252 / GCD(i) & "=" & Format(a(i) / GCD(i) / (252 / GCD(i)), "0.0000")
Next i
Label3.Caption = List2.ListCount
End Sub
Private Function GreatestCommonDivisor(ByVal M As Integer, N As Integer) As Integer
Do
r = M Mod N
M = N
N = r
Loop Until r = 0
GreatestCommonDivisor = M
End Function
展开全部
补充上面,5 个数字之和最大35,等于 40的概率 0%
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
任取 5 个数字的组合数= C10(5) = 252 种
5 个数字之和等于 10 的只有一种情况:0+1+2+3+4,所以等于 10 的概率 = 1/252 ≈0.397%
等于 20 的组合有:01289、01379、01469、01478、01568、02369、02378、02459、02468、03458、03467 共 11 种组合,所以等于 20 的概率 = 11/252 ≈ 4.365%
等于 30 的组合有:015789、024789、025689、034689、035679、045678 共 6 种组合,所以等于 30 的概率 = 6/252 ≈ 2.381%
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |