Skip to content

Commit 4f0ea35

Browse files
author
cpppy
authored
Create 190_Reverse_Bits.cc
1 parent 75d0247 commit 4f0ea35

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

190_Reverse_Bits.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
public:
3+
uint32_t reverseBits(uint32_t n) {
4+
uint32_t result=0;
5+
uint32_t tmp1=0;
6+
uint32_t tmp2=0;
7+
uint32_t tmp3=0;
8+
for(uint32_t i=0;i<32;++i){
9+
tmp1=n>>i;
10+
tmp2=tmp1&1;
11+
tmp3=result<<1;
12+
result=tmp3|tmp2;
13+
}
14+
return result;
15+
}
16+
};

0 commit comments

Comments
 (0)