作业帮 > 综合 > 作业

vb编程"编写一个求n!的阶乘函数F(n),利用该函数计算二项式系数Cmn=m!/(n!*(m-n)!

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/27 14:25:22
vb编程"编写一个求n!的阶乘函数F(n),利用该函数计算二项式系数Cmn=m!/(n!*(m-n)!
     编写一个求n!的阶乘函数F(n),利用该函数计算二项式系数Cmn=m!/(n!*(m-n)!);其中m>=n;m和n从键盘输入.
要VB编程
Private Sub Command1_Click()
Dim m As Integer, n As Integer
m = Int(InputBox("输入第一个整数"))
n = Int(InputBox("输入第一个整数"))
If m >= n Then
cmn = jiecheng(m) / (jiecheng(n) * jiecheng(m - n))
Print cmn
Else: MsgBox "输入数据有错"
End If
End Sub
Private Function jiecheng(x As Integer) As Double
jiecheng = 1
For i = 1 To x
jiecheng = jiecheng * i
Next
End Function