在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
C++ 存储类 auto
1 #include <iostream> 2 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 4 #include<iomanip> 5 #include<cmath> 6 using namespace std; 7 int main(int argc, char** argv) { 8 int s=1; 9 double n=1; 10 double t=1; 11 double pi=0; 12 while((fabs(t))>1e-7) 13 { 14 pi=pi+t; 15 n=n+2; 16 s=-s; 17 t=s/n; 18 } 19 pi=pi*4; 20 cout <<"pi="<<setiosflags(ios::fixed)<<setprecision(6)<<pi<<endl; 21 return 0; 22 }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论