c++, 计算正弦的近似值。sin(x)=x-x^3/3!+x^5/5!-x^7/7!+…… 要求用while、do-while和for循环语句
1 回答

慕后森
TA贡献1802条经验 获得超5个赞
Private Sub Command2_Click()
Dim x, an, sinx, n
x = Val(InputBox("x="))
an = x
n = 1
jc = 1
sinx = 0
Do Until Abs(an) < 10 ^ -6
sinx = sinx + an
n = n + 1
jc = jc * (2 * n - 2) * (2 * n - 1)
an = (-1) ^ (n - 1) * x ^ (2 * n - 1) / jc
Loop
Print sinx
End Sub
- 1 回答
- 0 关注
- 135 浏览
添加回答
举报
0/150
提交
取消