x 的平方根

 1 class Solution {
 2 public:
 3     int mySqrt(int x) {
 4         long res = x;
 5         while (res * res > x) {
 6             res = (res + x / res) / 2;
 7         }
 8         return res;
 9     }
10 };

 

posted @ 2018-04-26 21:56  newmoonn  阅读(107)  评论(0)    收藏  举报