1021

 1 #include <iostream>

 2 #include <iomanip>

 3 #include <cmath>

 4 using namespace std;

 5 int main()

 6  {float a,x0,x1;

 7   cin>>a; 

 8   x0=a/2;

 9   x1=(x0+a/x0)/2;

10   do

11     {x0=x1;

12      x1=(x0+a/x0)/2;

13      }

14   while(fabs(x0-x1)>=1e-5);

15   cout<<setiosflags(ios::fixed)<<setprecision(3)<<x1<<endl;

16   return 0;

17 }

 

你可能感兴趣的:(1021)