标签:upload one 注意 image nbsp ret blog ble 技术分享
给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
1 class Solution { 2 public: 3 double Power(double base, int exponent) { 4 int p = abs(exponent); 5 double r = 1.0; 6 while(p){ 7 if(p != 0) r *= base; 8 p --; 9 } 10 return exponent < 0 ? 1/ r : r; 11 } 12 };
23、给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。
标签:upload one 注意 image nbsp ret blog ble 技术分享
原文地址:http://www.cnblogs.com/olivegyr/p/7061454.html