参考代码:
#include <iostream> #include <math.h> #include <iomanip> using namespace std; int main() { double a,b,x1,x2; cin>>a; x1=a/2.0; x2=(x1+a/x1)/2.0; while(x1-x2>0.00001) { x1=(x2+a/x2)/2; x2=(x1+a/x1)/2; if(x1-x2<=0.00001) { break; } } if(x1-x2<=0.00001) { cout<<fixed<<setprecision(3)<<x1<<endl; } return 0; }
0.0分
0 人评分
2003年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:542 |
C语言程序设计教程(第三版)课后习题11.11 (C语言代码)浏览:768 |
C语言程序设计教程(第三版)课后习题6.2 (C语言代码)浏览:703 |
C语言程序设计教程(第三版)课后习题11.1 (C语言代码)浏览:609 |
1157题解浏览:711 |
K-进制数 (C语言描述,蓝桥杯)浏览:925 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:579 |
2006年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:342 |
川哥的吩咐 (C语言代码)浏览:609 |
模拟计算器 (C语言代码)浏览:2297 |