题解 | #数值的整数次方#
数值的整数次方
http://www.nowcoder.com/practice/1a834e5e3e1a4b7ba251417554e07c00
emmm
public class Solution {
public double Power(double base, int exponent) {
double basere=1;
if(exponent < 0){
for(int i =0;i<Math.abs(exponent);i++){
basere = basere * (1/base);
}
}
else{
for(int i =0;i<Math.abs(exponent);i++){
basere = basere * (base);
}
}
return basere;
}
}