69. Sqrt(x)(LeetCode)

Implement int sqrt(int x).

Compute and return the square root of x.

1 class Solution {
2 public:
3     int mySqrt(int x) {
4          long r = x;
5     while (r*r > x)
6         r = (r + x/r) / 2;
7     return r;
8     }
9 };
原文地址:https://www.cnblogs.com/wujufengyun/p/7192152.html