VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 13:02:24
VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数
xRJP,$))[I }(d"X4Mk$!](Bjqᣈ((פiIZq&̙3;w]a_ޕA)<<Kw)O0HgM]QT)U-D3#gUKR * BM]HP  54KaPC`զqPQǒ4ǎg\ ,Bk)\ #J-=8A.DDLAĭh7?6d|fikqwᨿC6&3H8R4u*epn~GLIk93DT0oO:

VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数
VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数

VB题,输入两个正整数M,N,求阶乘:Cmn=n!/m!(n-m)!,用fac函数
Private Sub Command1_Click()
Dim m As Integer,n As Integer
Dim c As Double
m = Val(InputBox("m="))
n = Val(InputBox("n="))
If n > 0 And m > 0 And n >= m Then
c = fac(n) / (fac(m) * fac(n - m))
MsgBox "所求结果为:" & c
Else
MsgBox "输入的数不符合要求!"
End If
End Sub
Function fac(n As Integer)
fac = 1
For i = 1 To n
fac = fac * i
Next i
End Function