标签:
public class Solution { public double Power(double base, int exponent) { int n; if(exponent==0){ return 1; } if(exponent<0){ if(base==0){ throw new RuntimeException("分母不能为0"); } n = -exponent; }else{ n = exponent; } double result=1; for(int i=0; i<n; i++){ result = result*base; } return exponent>0?result:(1/result); } }
标签:
原文地址:http://www.cnblogs.com/hesier/p/5582958.html