https://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00
逐项相乘
public static double Power(double base, int exponent) {
//保证不同时为0,先处理各自为0的情况
if (exponent == 0) return 1.0;
if (base == 0.0) return 0.0;
double ans = 1.0;
if (exponent < 0) {
base = 1 / base;
exponent = (-1) * exponent;
}
for (int i = 0; i < exponent; i++) {
ans *= base;
}
return ans;
}