求一个C语言程序,是一个求π的要求精确到小数点后100位的程序。。。。。。

如题所述

Private Sub Command1_Click()
Dim a As Long, b As Long, d As Long, e As Integer, f(801) As Long, g As Long
Dim i As Long
Dim res As String
Dim index As Long
a = 10000
c = 800
For i = 0 To c
f(i) = a / 5
Next i
'预留足够长的缓冲空间
res = Space(9000)
'指针变量,指出在哪里插入字符串
index = 1
Do While (c <> 0)
d = 0
g = c * 2
b = c
Do While (1)

d = d + f(b) * a
g = g - 1
f(b) = d Mod g
d = Fix(d / g)
g = g - 1
b = b - 1
If b = 0 Then GoTo 22
d = d * b
Loop
22:
c = c - 14
substr = Format(Fix(e + d / a), "0000")
'填充字符串的相应区间段数值
Mid$(res, index, 4) = substr
'调整指针变量
index = index + 5
If index > 101 Then Exit Do '只显示100位
e = d Mod a
Loop
'删除多余字符
res = Left$(res, index - 1)
Text1.Text = res
Debug.Print index
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-04-13
这个事要计算的,算法如下。
#include <stdio.h>

long a=10000, b, c=400, d, e, f[401], g;

void main()
{
for(;b-c;)
f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)
for(b=c; d+=f[b]*a, f[b]=d%--g, d/=g--, --b; d*=b);
scanf("%s");
}本回答被网友采纳
第2个回答  2012-04-14
#include <stdio.h>long a=10000, b, c=400, d, e, f[401], g

void main()
for(;b-c;)
f[b++]=a/5;
for(;d=0,g=c*2;c-=14,printf("%.4d",e+d/a),e=d%a)
for(b=c; d+=f[b]*a, f[b]=d%--g, d/=g--, --b; d*=b);
scanf("%s");
第3个回答  2012-04-13
printf("101.100%lf",n);

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网