LeetCode OJ:Reverse Bits(旋转bit位)
Reverse bits of a given 32 bits unsigned integer.
For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary as00111001011110000010100101000000).
注意应该做到平台无关性,需要做到这样的话应该声明一个uint32量然后一直向左移,知道得到 0 就可以得到uint32的位数大小 :
class Solution {
public:
uint32_t reverseBits(uint32_t n) {
uint32_t result = ;
for(uint32_t i = ; i != ; i <<= ){
result <<= ;
result |= (n & );
n >>= ;
}
return result;
}
};
LeetCode OJ:Reverse Bits(旋转bit位)的更多相关文章
- LeetCode 190. Reverse Bits (反转位)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- [LeetCode] 190. Reverse Bits 颠倒二进制位
Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 ...
- [LeetCode] 190. Reverse Bits 翻转二进制位
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- leetcode:Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- 【leetcode】Reverse Bits(middle)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Java for LeetCode 190 Reverse Bits
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- Leetcode 190. Reverse Bits(反转比特数)
Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in ...
- LeetCode 190. Reverse Bits (算32次即可)
题目: 190. Reverse Bits Reverse bits of a given 32 bits unsigned integer. For example, given input 432 ...
- Leetcode 190 Reverse Bits 位运算
反转二进制 class Solution { public: uint32_t reverseBits(uint32_t n) { uint32_t ans = ; ; i<; ++i,n &g ...
- Java [Leetcode 190]Reverse Bits
题目描述: everse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represente ...
随机推荐
- python3_requests模块详解
1.模块说明 requests是使用Apache2 licensed 许可证的HTTP库. 用python编写. 比urllib2模块更简洁. Request支持HTTP连接保持和连接池,支持使用co ...
- 【工具】Swagger2写接口注释
一.遇到的问题 作为一名coder,经常需要向别人提供接口,或者调用别人的接口.于是就有了接口参数是什么意思,要怎么传参数,返回值是什么意思……有多少调用方,就会有多少人来询问这些参数.如果是长时间之 ...
- Could not initialize class sun.awt.X11FontManager 异常问题
查了很多资料都是建议在 catalina.sh 中增加 -Djava.awt.headless=true \ 的配置. 加了没有效果. 后来发现是因为JDK版本问题,将JDK 8换成 JDK 7后 ...
- Java学习第三周摘要
20145307<Java程序设计>第三周学习总结 教材学习内容总结 认识对象 类类型 Java可区分为基本类型和类类型两大类型系统,其中类类型也称为参考类型.sun就是一个类类型变量,类 ...
- 20145312 实验四《Andoid开发基础》
20145312 实验四<Andoid开发基础> 实验内容 1. 安装Android Studio 2. 运行安卓AVD模拟器 3. 使用Android运行出模拟手机并显示自己的学号 实验 ...
- poj 2187:Beauty Contest(旋转卡壳)
Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 32708 Accepted: 10156 Description Bes ...
- cygwin下烧写文件到sd卡中
在cygwin下将firmware_sdcard.bin写入到sd卡中(cygwin需要以管理员身份启动) 1查看sd分区情况 cat /proc/partitions (为了找到sd卡的标记) 2 ...
- MySQL日常维护
删除MySQL 账号 use mysql delete from user where user='xiewenming'; 授权账号密码 GRANT SELECT,INSERT,UPDATE,DEL ...
- centos7配置安装redis
关闭防火墙:systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall开机启 ...
- 1568: [JSOI2008]Blue Mary开公司
1568: [JSOI2008]Blue Mary开公司 题目描述 传送门 题目分析 简单分析可以发现就是不停给出了\(n\)条直线,要求每次给出一条直线后求出所有直线在横坐标为\(x\)时\(y\) ...