231. Power of Two
来源:互联网 发布:免费海关数据 编辑:程序博客网 时间:2024/05/24 00:56
题目:
Given an integer, write a function to determine if it is a power of two.
思路:
本题思路很简单就是递归的调用
代码:
class Solution {public: bool isPowerOfTwo(int n) { if(n==1) return true; else if(n<1) return false; else { if ((n/2.0) == (n/2)) return isPowerOfTwo(n/2); else return false; } }};
阅读全文
1 0
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 231. Power of Two
- 第一章 PX4-Pixhawk-程序编译过程解析
- C++实现对简单的文件读写
- javascript中new Date()的浏览器兼容性问题
- java 字节流与字符流的区别
- github开源项目阅读
- 231. Power of Two
- 2017 计蒜之道 初赛 第五场 D UCloud 的安全秘钥(困难)[Hash]
- 链接带有中文不能正常访问
- 强大的Perl中的正则
- K2在2017 Q3 Forrester DPA软件报告中获评“表现强劲者”
- 第二章 PX4-Pixhawk-RCS启动文件解析
- java Long类型转为json后数据损失精度
- 微信小程序实现“鲜肉APP”首页效果
- 从磁盘到B树到B+树