取一个数的第i位
2016-05-14 20:41
176 查看
运用了一个函数,将X移i位,得到的数和1做位与运算,得到的就是X的第i位
#include <iostream> using namespace std; typedef unsigned long long ull; ull bits(ull x,int i) { return (x >> i) & 1ULL; } int main() { int testCase,i; while (cin>>testCase>>i) { cout<<bits(testCase,i)<<endl; } return 0; }
相关文章推荐
- synchronized和volatile比较
- 第18章 linux标准
- 使用.NET Framework提供的InstallUtil.exe安装Windows服务安装时遇到的2种常见错误
- CodeForces 672D Robin Hood(二分)
- JAVA中Long与Integer比较容易犯的错误
- 1098. Insertion or Heap Sort (25)【排序】——PAT (Advanced Level) Practise
- #define用法
- 读《世界是数字的》有感(补交)
- 电子商务平台
- C# 写系统日志
- CodeForces 672B Different is Good
- Java学习之继承
- Linux虚拟机小问题解决方法系列
- Callable Future Executor
- 剑指Offer--042-左旋转字符串
- 1097. Deduplication on a Linked List (25)【链表】——PAT (Advanced Level) Practise
- git-ssh 配置和使用
- TDPO和TSM客户端是如何实现ORACLE备份的
- Windows7上使用VMware安装MacOS虚拟机
- chisequre test