标签:leetcode
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); else{ if(n > 0) return x*pow(x*x,n/2); else return pow(x*x,n/2)/x; } }
标签:leetcode
原文地址:http://blog.csdn.net/laozhaokun/article/details/41256919