public double myPow(double x, int n) {
        double temp = 0;
        if(x==0.0) {
            return 0;
        }
        if(n==0){
            return 1;
        }
        if(n==1) {
            return x;
        }
        if(n<0){
           if(n==Integer.MIN_VALUE) {
             n=n+1;
             n=-n;  
             x=1/x;
             temp = myPow(x,n/2+1);
             return temp*temp;
           }else {
               n=-n;  
               x=1/x; 
           }
        }
        if(n%2==0) {
            temp = myPow(x,n/2);
            return temp*temp;
        }else {
            temp = myPow(x,n/2);
            return temp*temp*x;
        }
    }

 

相关文章:

  • 2021-10-24
  • 2021-07-03
  • 2021-11-26
  • 2021-11-21
  • 2021-09-07
  • 2021-11-23
  • 2021-12-24
  • 2021-10-15
猜你喜欢
  • 2021-10-12
  • 2021-08-18
  • 2022-01-04
  • 2021-09-08
  • 2021-10-09
  • 2021-08-17
  • 2021-05-31
相关资源
相似解决方案