码迷,mamicode.com
首页 > 其他好文 > 详细

9月9日刷题

时间:2015-09-10 00:26:23      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:

Sqrt(x)

http://www.guokr.com/question/461510/ 牛顿开方法

   public int sqrt(int x) {
        float X1 = 1f;
        float Xn = x;
        for (int i = 0; i < 20; ++i) {
            Xn = X1 / 2.f + x / (2 * X1);
            X1 = Xn;
        }
        return (int) X1;
    }

 

9月9日刷题

标签:

原文地址:http://www.cnblogs.com/fripside/p/4796200.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!