用VB编程计算 s=1-1⼀2+1⼀3-1⼀4+.....+(-1)的n-1次方⼀n,s精确到0.0001

用VB实现
2024-11-02 08:33:00
推荐回答(1个)
回答1:

Dim s, i As Integer
Dim n As Single
s = 0: n = 1: i = 1
While Abs(n) > 0.0001
n = (-1) ^ (i - 1) / i
s = s + n
i = i + 1
Wend
Print s