奥巴巴丶
2017-08-05 14:42求大佬看下开平方的函数(牛顿迭代法),感激涕零!
#include
#include
using namespace std;
//x(n + 1) = (xn+a/xn)/2
void NewtonSqrt(double a,double &x){
a = x - (x + a / x) / 2;
if (a<= 0.00001)
return;
x = (x + a / x) / 2;
NewtonSqrt(a, x);
}
void main(){
double a = 3;
double x = a / 2;
cout << x <<endl;
_getch();
}
- 点赞
- 回答
- 收藏
- 复制链接分享
3条回答
为你推荐
- 麻烦大佬看下为啥调用实例类密码函数无法用property
- python
- 1个回答
- c++日期类程序填空求大佬帮忙!
- c++
- 1个回答
- c++多选题求大佬帮忙!!!!
- c++
- 1个回答
- c++计算sinx的值求大佬帮忙
- c++
- 1个回答
- c++程序填空求大佬帮忙!!
- c++
- 1个回答
换一换