vb中如何计算Sin(x) = x-(x^3)/3!+(x^5)/5! -(x^7)/7!…
展开全部
Option Explicit
Private Sub Form_Click()
Dim x#, i&, A#, T#, S#, F#
x = InputBox("x = ? ")
If x = 0 Then
MsgBox "Sin(x)= 0"
Exit Sub
End If
T = x * x
A = x
S = A
F = 1
i = 3
Do
F = F * i * (i - 1)
A = -A * T
S = S + A / F
i = i + 2
Loop Until Abs(A / F) < 1E-16
MsgBox "Sin(x)=" & S
End Sub
Private Sub Form_Click()
Dim x#, i&, A#, T#, S#, F#
x = InputBox("x = ? ")
If x = 0 Then
MsgBox "Sin(x)= 0"
Exit Sub
End If
T = x * x
A = x
S = A
F = 1
i = 3
Do
F = F * i * (i - 1)
A = -A * T
S = S + A / F
i = i + 2
Loop Until Abs(A / F) < 1E-16
MsgBox "Sin(x)=" & S
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询