题解 | #数值的整数次方#
数值的整数次方
https://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00
class Solution { public: double Power(double base, int exponent) { if(exponent==0) return 1; if(exponent==1) return base; if(exponent>0) return base*Power(base, exponent-1); if(exponent<0) return (1/base)*Power(base, exponent+1); return 0; } };