输入X,利用公式e^x=1+x+x^2/2!+x^3/3!+…求e^x的近似值,直到最后一项绝对值小于-10^-6用VB (Microsoft Visual Studio 2005)这个软件
来源:学生作业帮助网 编辑:六六作业网 时间:2024/11/27 01:03:49
输入X,利用公式e^x=1+x+x^2/2!+x^3/3!+…求e^x的近似值,直到最后一项绝对值小于-10^-6用VB (Microsoft Visual Studio 2005)这个软件
输入X,利用公式e^x=1+x+x^2/2!+x^3/3!+…求e^x的近似值,直到最后一项绝对值小于-10^-6
用VB (Microsoft Visual Studio 2005)这个软件
输入X,利用公式e^x=1+x+x^2/2!+x^3/3!+…求e^x的近似值,直到最后一项绝对值小于-10^-6用VB (Microsoft Visual Studio 2005)这个软件
Dim a As Long, s As Long, D As String, e As Long, b As Long
D = 1: a = 1: s = 1
Do Until e > 6
D = ((2 * a) / (2 * a + 1)) * ((2 * a) / (2 * a - 1))
s = s * D
a = a + 1
b = 2 * s
e = Len(b) - InStr(b, ".")
Debug.Print D
DoEvents
Loop
Print b
Private Sub Command1_Click()
Print jsex(10)
End Sub
Function jsex(x As Integer) As Double
Dim jieguo As Double
Dim a As Double
Dim b As Double
Dim i As Integ...
全部展开
Private Sub Command1_Click()
Print jsex(10)
End Sub
Function jsex(x As Integer) As Double
Dim jieguo As Double
Dim a As Double
Dim b As Double
Dim i As Integer
jieguo = 1
a = x
b = 1
i = 1
Do While (a / b >= 0.000001)
jieguo = jieguo + a / b
a = a * x
i = i + 1
b = b * i
Loop
jieguo = jieguo + a / b
jsex = jieguo
End Function
来源: http://www.programbbs.com/bbs/view21-10192-1.htm
收起