Ai
1 Star 0 Fork 0

李璨/leetcode_practice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
50.pow-x-n.c 395 Bytes
一键复制 编辑 原始数据 按行查看 历史
李璨 提交于 2023-12-17 21:01 +08:00 . feat: 添加文件
/*
* @lc app=leetcode.cn id=50 lang=c
*
* [50] Pow(x, n)
*/
// @lc code=start
double myPow(double x, int n)
{
if (n == 0 || x == 1.0)
{
return 1.0;
}
if (n == 1)
{
return x;
}
if (n == -1)
{
return 1 / myPow(x, -n);
}
double t = myPow(x, n >> 1);
return (n & 1 ? x : 1) * t * t;
}
// @lc code=end
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Cham_1/leetcode_practice.git
git@gitee.com:Cham_1/leetcode_practice.git
Cham_1
leetcode_practice
leetcode_practice
master

搜索帮助