采取递归的方法,结果这个问题
public double Power(double base, int ex){
double res =0;
if(ex>=0){
res=way(base,ex);
}else {
res =way(base,-ex);
res = 1/res;
}
return res;
}
public double way(double base,int n){
if(n==0){
return 1;
} else {
return base*way(base,n-1);
}
}