int _tmain(int argc, _TCHAR* argv[])
{
int N;
cout<<"输入N的值:";
cin>>N ;
double x1 = 1;//初值
double x2 = x1/2.0+N/2.0/x1;
while( fabs(x2-x1)>0.001)
{
x1 = x2;
x2 = x1/2.0+N/2.0/x1;
}
cout<<x1<<endl;
system("pause");
return 0;
}
说是用的牛顿迭代,但是没看懂。为什么x1和x2要那么设置