首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

兑现指数函数Power

2012-10-17 
实现指数函数Power该题目不解释了,看代码,使用二分的思想,//int Power(int base, int exponent){int resul

实现指数函数Power


该题目不解释了,看代码,使用二分的思想,

//int Power(int base, int exponent){int result = 1;while (exponent){if (exponent & 1){result *= base;}base *= base;exponent >>= 1;}return result;}


Notice:

上述代码没考虑溢出的情况


热点排行