标签:
题目:
Given an integer, write a function to determine if it is a power of two.
非常简单的一道题目
class Solution { public: bool isPowerOfTwo(int n) { if (n <= 0) return false; if (n == 1) return true; if (n % 2 != 0) return false; else return isPowerOfTwo(n/2); return true; } };
标签:
原文地址:http://www.cnblogs.com/Doctengineer/p/5858670.html