作业帮 > 综合 > 作业

编写程序,求S=A!+B!+C!,阶乘的计算分别用Sub和Function过程两种方法来实现!

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/05/01 23:41:14
编写程序,求S=A!+B!+C!,阶乘的计算分别用Sub和Function过程两种方法来实现!
Function S(A As Integer, B As Integer, C As Integer) As Integer Dim x As Integer, y As Integer, z As Integer x = 1 y = 1 z = 1 For i = 1 To A x = x * i Next i For i = 1 To B y = y * i Next i For i = 1 To C z = z * i Next i S = x + y + z End Function Private Sub Command1_Click() Dim A As Integer, B As Integer, C As Integer A = 2 B = 2 C = 2 Print S(A, B, C) End Sub Sub S(A As Integer, B As Integer, C As Integer) Dim x As Integer, y As Integer, z As Integer, S As Integer x = 1 y = 1 z = 1 For i = 1 To A x = x * i Next i For i = 1 To B y = y * i Next i For i = 1 To C z = z * i Next i S = x + y + z Print S End Sub Private Sub Command1_Click() Dim A As Integer, B As Integer, C As Integer A = 2 B = 2 C = 2 S A, B, C End Sub
采纳哦