给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
import java.math.*;
public class Solution {
public double Power(double base, int exponent) {
int p = Math.abs(exponent);
double r = 1.0;
while(p !=0 ){
r *= base;
p --;
}
return exponent < 0 ? 1/ r : r;
return Math.pow(base, exponent);
}
}