LeetCodeOJ_231_Power of Two
来源:互联网 发布:淘宝上匡威正品店 编辑:程序博客网 时间:2024/06/18 17:03
答题链接
题目:
Given an integer, write a function to determine if it is a power of two.
Tags Math Bit Manipulation
Similar Problems (E) Number of 1 Bits
分析:
无
代码:
class Solution {public: bool isPowerOfTwo(int n) { if(n==0) return false; if(n==1) return true; //处理n>1的情况 int q; do{ q=n%2; if(q) break; n=n/2; }while(n>1); if(n==1) return true; else return false; }};
总结:
参考资料:无
结果:
0 0
- LeetCodeOJ_231_Power of Two
- two types of template
- two ways of multiThread
- Log of Grade Two
- Libgdx powers of two
- Power of Two
- [LeetCode] Power of Two
- 【LeetCode】Power of Two
- Power of Two
- power of two
- [Leetcode]Power of Two
- Power of Two
- [leetCode] Power of Two
- Power of Two
- 231Power of Two
- leetcode --Power of Two
- Power of Two
- leetcode: Power of Two
- python - 类 class
- Java核心---集合类
- Lua UnPack函数用法
- 寻找两个升序数组里的共同值
- UILabel属性, AttributedString字符串属性 (从网络搜集整理)
- LeetCodeOJ_231_Power of Two
- 黑马程序员——基础知识——正则及常见类
- 常用iOS、Mac框架和库及常用中文开发博客
- edditText正则限制特殊符号输入
- 鸟哥的Linux私房菜.基础学习篇(第三版)——互动出版网
- InputManager 的启动过程
- ListView 选中条目样式改变
- 结构型模式之桥接模式(跨平台视频播放器)
- TI DSP TMS320C66x学习笔记之TI官方读BMP程序(一)