> 其他 >
怎样用c语言编写求PI的近似值?
使用格里高利公式求PI的近似值要求精确到最后一项的绝对值小于10的负4次方?
人气:194 ℃ 时间:2020-02-03 04:56:00
解答
#include#includemain(){double t,pi;long int n,s;t=1.0;n=1;s=1;pi=0.0;while (fabs(t)>=1e-6){ pi=pi+t;n=n+2;s=-s;t=(float)(s)/(float)(n); }pi=pi*4;printf("pi=%lf\n"...
推荐
猜你喜欢
© 2026 79432.Com All Rights Reserved.
电脑版|手机版