当前位置:网站首页>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;
}边栏推荐
- 虽然不一定最优秀,但一定是最努力的!
- 泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
- Uniapp skills - scrolling components -1
- 信创产业现状、分析与预测
- Example analysis of QT learning 18 login dialog box
- Invalid Z-index problem
- jvm-对象生命周期
- Metal organic framework (MOFs) antitumor drug carrier | pcn-223 loaded with metronidazole | uio-66 loaded with ciprofloxacin hydrochloride( Exercise 6-2 using functions to sum special A-string sequences
- PCB中常用快捷键
猜你喜欢

Polestar美股上市:5.5万台交付如何支持得起超200亿美元估值

FPGA test method takes mentor tool as an example
[email"/>Folic acid modified metal organic framework (zif-8) baicalin loaded metal organic framework composite magnetic material (AU- [email

Programmable logic device software testing

“又土又穷”的草根高校,凭什么被称为“东北小清华”?

Exercise 6-6 use a function to output an integer in reverse order

Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs

JS Part 2

八大排序

Redis:字符串类型数据的操作命令
随机推荐
Mysql多表查询 #子查询
jvm-类加载
好看、好用、强大的手写笔记软件综合评测:Notability、GoodNotes、MarginNote、随手写、Notes Writers、CollaNote、CollaNote、Prodrafts、Noteshelf、FlowUs、OneNote、苹果备忘录
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
GRPC的四种数据流以及案例
Redis: redis data structure and key operation commands
Learn to punch in today
Exercise 10-2 recursive factorial sum
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code
UiO-66-COOH装载苯达莫司汀|羟基磷灰石( HA) 包裹MIL-53(Fe)纳米粒子|装载黄芩苷锰基金属有机骨架材料
别再问自己适不适合做软件测试了
信创产业现状、分析与预测
QT learning 19 standard dialog box in QT (top)
剑指 Offer 28. 对称的二叉树
[clean up the extraordinary image of Disk C]
Fabric. JS document
selenium 浏览器(1)
JVM垃圾回收机
Strategy, tactics (and OKR)
Metal organic framework material zif-8 containing curcumin( [email protected] Nanoparticles) | nano metal organic framework carry