#include <math.h>
#include <bitset>
using namespace std;
int mySqrt(int x) {
if(x <= 0)
{
return 0;
}
double c = x;
double old ;
do
{
old = c;
c = (c + x/c)/2;
}while (abs(old - c) > 0.0000001);
return int(c);
}
int main()
{
cout << mySqrt(8) <<endl;
getchar();
return 0;
}
11-30
774
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
11-29
410
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
06-08