#include <stdio.h>
int main()
{
int n;
printf("please enter a number:");
scanf("%d",&n);
if(n&(n-1)==0)
{
printf("yes\n");
}
else
{
printf("no\n");
}
return 0;
}
&运算符运用之判断一个数是不是2^n
时间: 2025-01-13 04:40:50
#include <stdio.h>
int main()
{
int n;
printf("please enter a number:");
scanf("%d",&n);
if(n&(n-1)==0)
{
printf("yes\n");
}
else
{
printf("no\n");
}
return 0;
}
&运算符运用之判断一个数是不是2^n