Implement
pow(x, n).
class Solution {public:
double pow(
double x,
int n)
{
if(n==
1)
return x;
if(n==-
1)
return 1/x;
if(n==
0)
return 1;
double result=
1;
double tmp=pow(x,n/
2);
return tmp*tmp*pow(x,n-n/
2*
2);
return result;
}
};
Pow(x, n),布布扣,bubuko.com
Pow(x, n)
原文:http://www.cnblogs.com/erictanghu/p/3759377.html