文章目录 题目描述代码实现 题目描述 代码实现 public static double myPow(double x,int n) { if (n==0) { return 1; } if (n==1) { return x; } if (n==-1) { return 1/x; } double half=myPow(x, n/2); // System.out.println("half:"+half); double rest=myPow(x, n%2); // System.out.println("rest:"+rest); return rest*half*half; }