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

algorithm

时间:2015-09-15 16:22:24      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

求平方根

class SqRoot{

  void calcRoot(double z){

    double x=1;double y=z/x;

    while(Math.abs(x-y)>1E-10)

    {

      x=0.5*(x+y); y=z/x;

    }

    System.out.println(x);

  }

}

algorithm

标签:

原文地址:http://www.cnblogs.com/jack-xu/p/4810515.html

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