标签:generate 整数 out des sony [] div 一个 ==
package new_offer; /** * 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方 * @author Sonya * */ public class N12_Power { public double Power(double base, int exponent) { double power=1.0; if(exponent==0) return 1; for(int i=0;i<Math.abs(exponent);i++) { power=power*base; } if(exponent<0)return 1/power; return power; } public static void main(String[] args) { // TODO Auto-generated method stub N12_Power n12=new N12_Power(); System.out.println(n12.Power(3, 5)); System.out.println(n12.Power(2, -3)); } }
标签:generate 整数 out des sony [] div 一个 ==
原文地址:https://www.cnblogs.com/kexiblog/p/10885340.html