编写程序,求S=A!+B!+C!,阶乘的计算分别用Sub和Function过程两种方法来实现!
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/25 10:54:35
编写程序,求S=A!+B!+C!,阶乘的计算分别用Sub和Function过程两种方法来实现!
编写程序,求S=A!+B!+C!,阶乘的计算分别用Sub和Function过程两种方法来实现!
编写程序,求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
采纳哦