题目
计算π的近似值,精确到小数点后6位 设计vb程序 需要代码 VB里面的 π/2=2^2/1*3 ×4^4/3*5 ×.×(
提问时间:2020-08-10
答案
你给的公式不对!应该是π/2=2^2/1*3 ×4^2/3*5 ×.×(
这个公式求的精度不高!代码如下:
Dim PI1 As Double
Dim PI2 As Double
Dim Temp As Double
Dim n As Double
PI1 = 0:PI2 = 2:n = 2
While PI2 - PI1 > 0.000001
PI1 = PI2
Temp = (n * n) / ((n - 1) * (n + 1))
PI2 = PI2 * Temp
n = n + 2
Wend
Me.Text1.Text = PI2
这个公式求的精度不高!代码如下:
Dim PI1 As Double
Dim PI2 As Double
Dim Temp As Double
Dim n As Double
PI1 = 0:PI2 = 2:n = 2
While PI2 - PI1 > 0.000001
PI1 = PI2
Temp = (n * n) / ((n - 1) * (n + 1))
PI2 = PI2 * Temp
n = n + 2
Wend
Me.Text1.Text = PI2
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
热门考点
- 1There are not__rooms for all the guests.A:lots of B:a little C:enough D:plenty of
- 2去北京最好是什么时候?(英文翻译)
- 3解二元一次方程组;2x-y=3 3x+4y=10
- 4一水平传送带以6m/s速度顺时针转动,一物块以8m/s速度从传送带右端冲上传送带,动摩擦因数0.5,g=10m/s^2,求物块向左最多能滑到距传送带右端多远的地方.
- 5有一只小猴子想去摘树顶的椰子,现在已知这颗椰树高10米,而这只小猴子在1分钟之内是可以向上爬3米……
- 6A,B,C,为正整数,且A²+C²=20,B²+C²=25,求A,B,C,的值
- 7求解释一个英文句子
- 8英语翻译
- 9乙酸乙酯制备实验反应的一个主要的化学方程式
- 10My father _____ the telephone to call the police.A hurry B hurry to C hurried to D hurried