Given an integer, write a function to determine if it is a power of two. 题意分析: 通过计算可以知,当n = 30时,pow(2,n)为int型最大的数。 123456 class Solution {public: bool (int n) { return (n <= 0) ? false : ((int)pow(2,30) % n == 0); }}; 赞微海报分享
近期评论