staticintpow(int a,int n){if(n ==0)return1;int res = a;int ex =1;//能翻while((ex <<1)<= n){//翻
res = res * res;//指数
ex <<=1;}//不能翻//差n-ex次方没有去乘到结果里面return res *pow(a, n - ex);}
设计一个高效的求a的n次幂的算法代码:static int pow(int a, int n) {if (n == 0) return 1;int res = a;int ex = 1;//能翻while ((ex << 1) <= n) {//翻res = res * res;//指数ex <<= 1;}//不能翻//差n-ex次方没有去乘到结果里面return res * pow(a, n - ex);}...