p { margin-bottom: 0.25cm; line-height: 120% }
一、理论证明
p { margin-bottom: 0.25cm; line-height: 120% }
由以上推导易得公式为:Xk+1 = (Xk +a/Xk)/2
代码实现:
class Solution { public: int mySqrt(int x) { double last_pre = 3.000; for(int i = 0;i < 32;i++){ double cur_num = (pre_num + double(x)/pre_num)/2.0000; last_num = cur_num; } return last_num; } };
时间: 2024-10-05 20:10:58