190. Reverse Bits

来源:互联网 发布:手机指画软件 编辑:程序博客网 时间:2024/06/07 03:12

题目:https://leetcode.com/problems/reverse-bits/

代码:

public class Solution {    // you need treat n as an unsigned value    public int reverseBits(int n) {        int bit;        int res=0;        for(int i=0;i<32;i++,n=n>>1)        {            bit = (1&n);            res = res|(bit<<(31-i));        }        return res;    }}
0 0
原创粉丝点击