当前位置:网站首页>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;
}边栏推荐
- Exercise 6-2 using functions to sum special A-string sequences
- 必贝特医药冲刺科创板:年营收97万亏损1.37亿 拟募资20亿
- JS get DPI, PX to cm, cm to PX
- 泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
- Redis: commandes d'action pour les données de type chaîne
- The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log
- C library function - qsort()
- QT learning 21 standard dialog box in QT (Part 2)
- Exercise 10-1 judge the three digits that meet the conditions
- Exercise 6-6 use a function to output an integer in reverse order
猜你喜欢

Example analysis of QT learning 18 login dialog box

Exercise 10-1 calculate the sum of 1 to n using recursive functions

Leetcode(4)——寻找两个正序数组的中位数

Solution to failure or slow downloading of electron when electron uses electron builder to package

Exercise 10-8 recursive implementation of sequential output of integers

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

The small project (servlet+jsp+mysql+el+jstl) completes a servlet with login function, with the operation of adding, deleting, modifying and querying. Realize login authentication, prevent illegal log

修改数据库中的记录为什么报这个错

玖逸云黑免费无加密版本源码

JS Part III
随机推荐
Solution to failure or slow downloading of electron when electron uses electron builder to package
战略、战术(和 OKR)
Thinking about the arrangement problem in the backtracking problem (leetcode questions 46 and 47)
信创产业现状、分析与预测
Exercise 6-2 using functions to sum special A-string sequences
可编程逻辑器件软件测试
jvm-运行时数据区
Exercise 6-1 classify and count the number of characters
Redis: operation command of string type data
JVM object lifecycle
TS code automatically generates JS
Common plug-ins for vite project development
7-9 find a small ball with a balance
JS get DPI, PX to cm, cm to PX
Current situation, analysis and prediction of information and innovation industry
C library function - qsort()
Raft agreement
[clean up the extraordinary image of Disk C]
天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪
虽然不一定最优秀,但一定是最努力的!