inline bool isSet(const unsigned int &A, const int &pos) {
return A & (1 << (pos - 1));
}
inline void setBit(unsigned int &num, const int &pos) {
num = num | (1 << (32 - pos));
}
unsigned int Solution::reverse(unsigned int A) {
unsigned int res = 0;
for(int pos = 1; pos <= 32; pos++)
if(isSet(A, pos))
setBit(res, pos);
return res;
}
unsigned int Solution::reverse(unsigned int A) {
unsigned int res = 0;
for(int pos = 1; pos <= 32; pos++)
if(A & (1 << (pos - 1)))
res = res | (1 << (32 - pos));
return res;
}