标签:sp bs ef as return ca nbsp public c
在某些情况下有误差
public static int Sqrt(int a)
{
switch (a)
{
case 0:
return 0;
case 1:
case 2:
case 3:
return 1;
default:
int n = a / 2;
int m = (n + a / n) / 2;
while (n > m)
{
n = m;
m = (n + a / n) / 2;
}
return m;
}
}
标签:sp bs ef as return ca nbsp public c
原文地址:http://www.cnblogs.com/Asuphy/p/4042718.html