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; }
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; }