2015年11月24日

位运算问题

摘要: n & (n - 1)的作用:把n中为1的最低位变为0.Power of TwoGiven an integer, write a function to determine if it is a power of two.解法:2的次幂的特征是有且仅有一位为1,其余为均为零。故可利用判断n & (... 阅读全文

posted @ 2015-11-24 12:10 ShinningWu 阅读(142) 评论(0) 推荐(0) 编辑

导航