Advertisement
Josif_tepe

Untitled

Dec 30th, 2022
952
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     uint32_t reverseBits(uint32_t n) {
  4.         uint32_t result = 0;
  5.         int stepen = 31;
  6.         while(n > 0) {
  7.             int bit = n % 2;
  8.             n /= 2;
  9.             if(bit == 1) {
  10.                 result += (1 << stepen);
  11.             }
  12.             stepen--;
  13.         }
  14.         return result;
  15.     }
  16. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement