X=根号a
X(n+2)=1/2(Xn+a/Xn)
double sqroot(double a)
{
double x0,x1;
x0=a/2;
x1=(x0+a/x0)/2;
do{
x0=x1;
x1=(x0+a/x0)/2;
}( (x1>x0 ? x1-x0 : x0-x1)<1e-8);
return x1;
}
#include
using namespace std;
void main(void)
{
float x=0.0;
cin>>x;
float xhalf = 0.5l * x;
float num = x;
int i = *(int *)& x;
i = 0x5f375a86 - (i >> 1);
x = *(float * ) & i;
x = x * (1.5f - xhalf*x*x);
x = x * (1.5f - xhalf*x*x);
x = x * (1.5f - xhalf*x*x);
cout<
穷举就可以了