标签:
反转二进制
1 class Solution { 2 public: 3 uint32_t reverseBits(uint32_t n) { 4 uint32_t ans = 0; 5 for (int i = 0; i<32; ++i,n >>=1){ 6 ans = (ans<< 1)|(n & 1); 7 } 8 return ans; 9 } 10 };
Leetcode 190 Reverse Bits 位运算
原文地址:http://www.cnblogs.com/onlyac/p/5270346.html