LeetCode 231

时间:2023-03-08 15:32:53

Power of Two

Given an integer, write a function to determine if it is a power of two.

 /*************************************************************************
> File Name: LeetCode231.c
> Author: Juntaran
> Mail: Jacinthmail@gmail.com
> Created Time: 2016年05月10日 星期二 02时55分46秒
************************************************************************/ /************************************************************************* Power of Two Given an integer, write a function to determine if it is a power of two. ************************************************************************/ #include "stdio.h" int isPowerOfTwo(int n) {
int temp = (n> && !(n&(n-)));
return temp;
} int main()
{
int n = ;
int ret = isPowerOfTwo(n);
printf("%d\n",ret); n = ;
ret = isPowerOfTwo(n);
printf("%d\n",ret); return ;
}