Pow(x, n)
来源:互联网 发布:c语言如何使用graphics 编辑:程序博客网 时间:2024/06/08 05:28
Implement pow(x, n).
//此题思路,第一种最简单的迭代,第二种基本的递归,第三种,分治法。
// x^n = x^(n/2)*x^(n/2)*x(n%2)
//再者本题注意的细节,x=0,n=0,n负数等
double pow(double x, int n) { double temp; if(x == 0)return 0; if(n==0)return 1; if (n==1){return x;}if(n == -1){ return 1/x;}if (n%2 == 0)//偶数{temp = pow(x,n/2);return temp*temp;}else{temp = pow(x,n/2);if(n>0)return temp*temp*x;elsereturn temp*temp*1/x;} }
- Pow(x, n) / Super Pow
- LeetCode: Pow(x, n)
- LeetCode Pow(x,n)
- [Leetcode] Pow(x, n)
- LeetCode: Pow(x, n)
- Leetcode: Pow(x,n)
- [LeetCode] Pow(x, n)
- [Leetcode] Pow(x,n)
- Pow(x, n)
- 【leetcode】Pow(x, n)
- Pow(x, n)
- 求 pow(x, n)
- [LeetCode]Pow(x, n)
- Pow(x,n)
- Pow(x, n)
- Pow(x, n)
- [leetcode]Pow(x, n)
- LeetCode-Pow(x, n)
- 二维数组大集合。
- IOS手势总结与UIResponder
- eclipse中使用findbugs插件
- 双链表基本操作
- SGU 153 Playing with matches(博弈)
- Pow(x, n)
- 抽象类、密封类及类成员(C# 编程指南)
- Sicily 1041. Pushing Boxes
- 第十五周项目2-杨辉三角
- Access denied for user ''@'localhost' to database 'mysql'
- MySQL鲜为人知的几个特殊技巧
- HTML基本标签--表单
- MyEclipse提示过期“Your 30-day trial of MyEclipse has expired.”
- 一道经常出现的字符串内存地址问题的笔试题