当前位置:网站首页>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;
}边栏推荐
- JVM object lifecycle
- [combinatorics] permutation and combination (examples of combinatorial number of multiple sets | three counting models | selection problem | combinatorial problem of multiple sets | nonnegative intege
- Exercise 6-2 using functions to sum special A-string sequences
- JS general form submission 1-onsubmit
- Raft agreement
- allegro,orcad, net alias,port,off-page connector之间的异同点和如何选取
- 泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
- GRPC的四种数据流以及案例
- QT learning 23 layout manager (II)
- 金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
猜你喜欢

7-7 12-24 hour system

JS matrix zero

jvm-运行时数据区

x86汇编语言-从实模式到保护模式 笔记

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

Redis:字符串類型數據的操作命令

QT learning 20 standard dialog box in QT (middle)

消息订阅与发布

JS input number and standard digit number are compared. The problem of adding 0 to 0

JVM runtime data area
随机推荐
交联环糊精金属有机骨架负载甲氨蝶呤缓释微粒|金属-有机多孔材料UiO-66负载黄酮苷类药物|齐岳
jvm-对象生命周期
MongoDB索引
Exercise 6-1 classify and count the number of characters
金属有机骨架材料ZIF-8包载姜黄素([email protected]纳米颗粒)|纳米金属有机框架搭载雷帕霉素|科研试剂
Leetcode (4) -- find the median of two positively ordered arrays
Uniapp skills - scrolling components -1
Similarities and differences of sessionstorage, localstorage and cookies
Scroll detection of the navigation bar enables the navigation bar to slide and fix with no content
QT learning 25 layout manager (4)
C library function - qsort()
Interface for querying IP home
Leetcode (4) - - trouver la médiane de deux tableaux ordonnés positifs
concat和concat_ws()区别及group_concat()和repeat()函数的使用
Configure stylelint
Metal organic framework MOFs loaded with non steroidal anti-inflammatory drugs | zif-8 wrapped Prussian blue loaded quercetin (preparation method)
Raft 协议
selenium 浏览器(1)
金属有机骨架MIL-88负载阿霉素DOX|叶酸修饰UiO-66-NH2负载阿霉素[email protected]纳米粒子
MongoDB数据库入门的常用命令