sqrtx-开平方
Implementint sqrt(int x).
Compute and return the square root of x.
逐次逼近
class Solution { public: int sqrt(int x) { if(x<2) return x; int left=1,right=x/2; int mid; while(left<=right) { mid=left+(right-left)/2; if(x/mid <mid) right=mid-1; else if(x/mid>mid) left=mid+1; else return mid; } return right; } };
联系方式:emhhbmdfbGlhbmcxOTkxQDEyNi5jb20=