c++, 计算正弦的近似值。sin(x)=x-x^3/3!+x^5/5!-x^7/7!+…… 要求用while、do-while和for循环语句
1个回答
2018-05-06 · 知道合伙人互联网行家
关注
展开全部
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
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
追问
大神你好 这一步有点疑问
an = (-1) ^ (n - 1) * x ^ (2 * n - 1) / jc
c++里面无法表示x的次方呀
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询