当前位置:网站首页>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 10-1 judge the three digits that meet the conditions
- Page generation QR code
- Duet date picker (time plug-in that can manually enter the date)
- Global event bus
- 别再问自己适不适合做软件测试了
- JS new challenges
- Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
- JVM runtime data area
- [combinatorics] permutation and combination (two counting principles, examples of set permutation | examples of set permutation and circle permutation)
- C library function - qsort()
猜你喜欢

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

Jiuyi cloud black free encryption free version source code

Vite project commissioning

天图投资冲刺港股:资产管理规模249亿 投了小红书与奈雪

Concat and concat_ Ws() differences and groups_ Use of concat() and repeat() functions

Page generation QR code

Redis:字符串類型數據的操作命令
[email "/>Doxorubicin loaded on metal organic framework MIL-88 DOX | folic acid modified uio-66-nh2 doxorubicin loaded [email

小项目(servelt+jsp+mysql+EL+JSTL)完成一个登录功能的Servlet,具有增删改查的操作。实现登录身份验证,防止非法登录,防止多点登录,记住用户名密码功能。

protobuf与grpc
随机推荐
jvm-运行时数据区
Why are grass-roots colleges and universities with "soil and poverty" called "Northeast small Tsinghua"?
js . Find the first palindrome string in the array
信创产业现状、分析与预测
7-10 calculate salary
How to bold text in AI
Mysql多表查询 #子查询
MongoDB索引
泰凌冲刺科创板:拟募资13亿 国家大基金与小米长江是股东
Message subscription and publishing
Comprehensive evaluation of good-looking, easy-to-use and powerful handwriting note taking software: notability, goodnotes, marginnote, handwriting, notes writers, collanote, collanote, prodrafts, not
Selenium browser (1)
Global event bus
js 2023. String pair equal to the target string after connection
Article content typesetting and code highlighting
JS continues to explore...
TS code automatically generates JS
page owner特性浅析
Example analysis of QT learning 18 login dialog box
Webpage connection database ~ simple implementation of addition, deletion, modification and query complete code