vb 根据公式计算π的近似值π/2=1+1/3+1/3*2/5+1/3*2/5*3/7

问题描述:

vb 根据公式计算π的近似值π/2=1+1/3+1/3*2/5+1/3*2/5*3/7


#include <stdio.h>main(){ long i,a=1,b=3; double p=1,t=1,t1=0; while(t-t1>=1e-8) {  t1=t;  t*=a/b;  p+=t;  a++;  b+=2; } printf("...这是什么程序算的?

哦上面这个是C的。VB的如下:

Private Sub Command1_Click()

  a = 1: b = 3: p = 1: t = 1: t1 = 2

  While t1 - t >= 0.00000001

    t1 = t: t = t * a / b

    p = p + t: a = a + 1: b = b + 2

  Wend

  Print "Pi="; 2 * p

End Sub

ok请采纳。