牛顿迭代法求平方根
class Solution {
public:
/**
*
* @param x int整型
* @return int整型
*/
int mysqrt(int x) {
double t = x;
while(abs(t * t - x) > 0.0001) {
t = t - (t*t - x)/(2*t);
}
return (int)t;
}
};