给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
public class Solution { public double Power(double base, int exponent) { if(exponent == 0)return 1; if(exponent == 1)return base; boolean flag = false; if(exponent < 0) { exponent = -exponent; flag = true; } double pow = Power(base * base, exponent/2); if(exponent/2 == 1) { pow = pow * base; } return flag == true?1/pow:pow; } }