当前位置:网站首页>7-15 calculation of PI
7-15 calculation of PI
2022-07-03 14:14:00 【Big fish】
According to the following relation , Find the value of pi , Until the value of the last item is less than the given threshold .

Input format :
The input gives less than... On one line 1 The threshold of .
Output format :
Output the approximate PI satisfying the threshold condition in one line , Output after decimal point 6 position .
sample input :
0.01
sample output :
3.132157Code thinking :
#include <stdio.h>
int main()
{
double PI=1;
double t;
double num=1.0;
int i=1;
scanf("%lf",&t);
while(num>t) // Stop until the last item is less than the threshold
{
num=num*i/(i*2+1); // The numerator in each fraction is a factorial , The denominator is an arithmetic sequence
PI+=num;
i++;
}
printf("%.6f\n",PI*2);
return 0;
}边栏推荐
- Article content typesetting and code highlighting
- GRPC的四种数据流以及案例
- js 2023. String pair equal to the target string after connection
- 编程语言:类型系统的本质
- [acnoi2022] guess numbers
- JS Part 2
- Redis: redis data structure and key operation commands
- 2021年区域赛ICPC沈阳站J-Luggage Lock(代码简洁)
- 7-10 calculate salary
- Exercise 8-2 calculate the sum and difference of two numbers
猜你喜欢

QT learning 22 layout manager (I)

TS code automatically generates JS

Similarities and differences between Allegro, OrCAD, net alias, port, off page connector and how to select them

信创产业现状、分析与预测

Exercise 6-1 classify and count the number of characters

Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content

Exercise 8-8 moving letters

Redis:字符串类型数据的操作命令

Nucleic acid modified metal organic framework drug carrier | pcn-223 metal organic framework encapsulated ad adamantane | zif-8 encapsulated adriamycin (DOX)

Exercise 10-8 recursive implementation of sequential output of integers
随机推荐
Exercise 9-3 plane vector addition
JVM garbage collector
etcd集群权限管理和账号密码使用
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
concat和concat_ws()区别及group_concat()和repeat()函数的使用
Print. JS -- web page file printing
Generate directories from web content
npm install卡住与node-npy的各种奇怪报错
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry
JS general form submission 1-onsubmit
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
Current situation, analysis and prediction of information and innovation industry
Uniapp skills - dom display and hiding
玖逸云黑免费无加密版本源码
Exercise 6-1 classify and count the number of characters
Article content typesetting and code highlighting
Cross linked cyclodextrin metal organic framework loaded methotrexate slow-release particles | metal organic porous material uio-66 loaded with flavonoid glycosides | Qiyue
MongoDB数据库入门的常用命令
JS get DPI, PX to cm, cm to PX
Uniapp skills - scrolling components -1