题目描述
给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方
public class Solution { public double Power(double num, int n) { double s=1,tmp=n; if(n<0) n=-1*n; //if(n==1) return s; for(int i=1;i<=n;i++){ s*=num; } if(tmp>=0) return s; return 1.0/s; }}