討論串[問題] a的b次方實作時間logb之遞迴寫法
共 6 篇文章
內容預覽:
未看回覆先試. int fastpow(int num, int pow) {. if(pow>0) {. if(pow&1) {. return fastpow(num, pow-1)*num;. //看過之後覺得orz... //return fastpow(num*num, pow>>1)*n
(還有136個字)
內容預覽:
http://nopaste.csie.org/b7518. 完全只是把原po的非遞迴改成遞迴 = =. int fastpow_initial(int a, int b). {. return fastpow_recursive(a,b,1);. }. int fastpow_recursive(
(還有61個字)