Implement pow(x, n).
原题链接:https://oj.leetcode.com/problems/powx-n/
public double pow(double x, int n) {
if(n== 0)
return 1;
if(n == 1)
return x;
if(n % 2 ==0)
return pow(x*x,n/2);
...
分类:
其他好文 时间:
2014-11-19 01:19:41
阅读次数:
157
原题地址:https://oj.leetcode.com/problems/powx-n/题意:Implement
pow(x,n).解题思路:求幂函数的实现。使用递归,类似于二分的思路,解法来自Mark Allen Weiss的《数据结构与算法分析》。代码:class
Solution: #...
分类:
编程语言 时间:
2014-06-11 08:59:33
阅读次数:
317