编程;VB 编写一个过程,用来计算下列表达式的值,并在事件过程中调用。 S=1+1/2!+1/3!+...+1/n!
3个回答
展开全部
Sub AA(inta As Integer)
Dim S As Double
Dim i, j As Integer
Dim K As Single
S = 1
For i = 2 To inta
K = 1
For j = 1 To i
K = K * j
Next
S = S + 1 / K
Next
MsgBox S
End Sub
Dim S As Double
Dim i, j As Integer
Dim K As Single
S = 1
For i = 2 To inta
K = 1
For j = 1 To i
K = K * j
Next
S = S + 1 / K
Next
MsgBox S
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-11-29
展开全部
Sub s(n As Integer, ByRef sum As Double)
Dim jc As Double
jc = 1
For i = 1 To n
jc = jc * i
sum = sum + 1 / jc
Next i
End Sub
Private Sub Command1_Click()
Dim sum As Double
Call s(Val(InputBox("n=")), sum)
Print sum
End Sub
Dim jc As Double
jc = 1
For i = 1 To n
jc = jc * i
sum = sum + 1 / jc
Next i
End Sub
Private Sub Command1_Click()
Dim sum As Double
Call s(Val(InputBox("n=")), sum)
Print sum
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Form_Activate()
a 5
End Sub
Sub a(n As Long)
Dim i As Long
For i = 1 To n
Sum = Sum + 1 / f(i)
Next i
Print Sum
End Sub
Function f(n As Long) As Long
Dim i As Long
f = 1
For i = 1 To n
f = f * i
Next i
End Function
a 5
End Sub
Sub a(n As Long)
Dim i As Long
For i = 1 To n
Sum = Sum + 1 / f(i)
Next i
Print Sum
End Sub
Function f(n As Long) As Long
Dim i As Long
f = 1
For i = 1 To n
f = f * i
Next i
End Function
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询