2 回答
SMILET
TA贡献1796条经验 获得超4个赞
java实现开根号的运算:
public static void main(String[] args) { long start = System.currentTimeMillis(); double
target=9876543212345d; double result =sqrt(target);
System.out.println("sqrt耗时:"+(System.currentTimeMillis()-start)+",result:"+result);
start=System.currentTimeMillis();
result =SqrtByBisection(target, 0);
System.out.println("SqrtByBisection耗时:"+(System.currentTimeMillis()
start)+",result:"+result);
start=System.currentTimeMillis();
result = SqrtByNewton(target, 0);
System.out.println("SqrtByNewton耗时:"+(System.currentTimeMillis()
start)+",result:"+result);
}
添加回答
举报
0/150
提交
取消