标签:bsp 数值的整数次方 class style nbsp code -- public int
class Solution { public: double Power(double base, int exponent) { if (exponent > 0) { double sqr = 1; int i = 0; for (int i = 0; i < exponent; ++i) { sqr = sqr*base; } return sqr; } else if (exponent == 0) return 1; else { int zhengshu = abs(exponent); double sqr = 1; int i = 0; for (int i = 0; i < zhengshu; ++i) { sqr = sqr*base; } return (1/sqr); } } };
标签:bsp 数值的整数次方 class style nbsp code -- public int
原文地址:http://www.cnblogs.com/159269lzm/p/7295287.html