首页 > 其他 > 详细

190. Reverse Bits (Binary)

时间:2018-07-31 10:20:56      阅读:110      评论:0      收藏:0      [点我收藏+]

>>>表示无符号右移,左边空出的位以0填充
>>=右移赋值
>>>=无符号右移赋值
<<= 左移赋值
<<左移

 

 1 class Solution {
 2     // you need treat n as an unsigned value
 3     public int reverseBits(int n) {
 4         int res = 0;
 5         for(int i = 0; i < 32; i++) {
 6             res <<= 1;
 7             res += n & 1;
 8             n >>>= 1;
 9             
10         }
11         return res;   
12     }
13 }

 

190. Reverse Bits (Binary)

原文:https://www.cnblogs.com/goPanama/p/9393857.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!