Buf*_*lls 5 java algorithm math
我知道如何推动战俘(双x,中国)
public class Solution {
public double myPow(double x, int n) {
if (n == 0)
return 1;
if (n % 2 == 0) {
return myPow(x * x, n / 2);
} else {
if (n > 0)
return x * myPow(x, n - 1);
else
return 1 / x * myPow(x, n + 1);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是如何使它处理双y?