69. Sqrt(x)
来源:互联网 发布:台湾处境现状 知乎 编辑:程序博客网 时间:2024/06/05 08:53
Implement int sqrt(int x)
.
Compute and return the square root of x.
计算x的算术平方根
class Solution
{
public:
int mySqrt(int x)
{
double begin(0);
double end(x);
if(x==0)
return 0;
if(x==1)
return 1;
double result (0);
double mid (0);
while(abs(result-x) > 0.000001)
{
mid=(begin+end)/2;
result=mid*mid;
if(result>x)
end=mid;
else
begin=mid;
}
return (int)mid;
}
};
阅读全文
0 0
- LeetCode 69. Sqrt(x)
- LeetCode 69.Sqrt(x)
- LeetCode --- 69. Sqrt(x)
- [Leetcode] 69. Sqrt(x)
- [leetcode] 69.Sqrt(x)
- 69.Sqrt(x)
- 69. Sqrt(x)
- Leetcode-69.Sqrt(x)
- leetcode--69.sqrt(x)
- 69. Sqrt(x)
- LeetCode 69. Sqrt(x)
- leetcode 69. Sqrt(x)
- 【LeetCode】69. Sqrt(x)
- 69. Sqrt(x) LeetCode
- 69. Sqrt(x)
- 69. Sqrt(x)
- [leetcode] 69. Sqrt(x)
- 69. Sqrt(x)
- springboot security基于注解配置权限与CAS单点登录配置。
- Redis的持久化
- 对芯片操作的一点总结
- windows上安装tensorflow时报错,“DLL load failed: 找不到指定的模块”的解决方式 最近打算开始研究一下机器学习,今天在windows上装tensorflow花了点功夫
- String 判断字符串是否包含某个字符
- 69. Sqrt(x)
- leach-matlab
- 【Android笔记-异常-7】FrameLayout要嵌套在LinearLayout里否则布局有问题。
- Spark源码解析之SparkSql
- Mybatis 循环遍历 foreach
- 网站响应式页面查看工具源代码
- Windows下安装MySQL解压缩版
- TensorFlow(三) 常用的 Python API
- [bzoj1131][POI2008]Sta