Answer the question
In order to leave comments, you need to log in
Is a number a power of two in c++ without using if?
I write
return a && (a & (a - 1)) == 0);
it seems to help, but how to make it so that if it is a degree, "+" or "true" is written without if,
or what error is in the code.
#include
#include
using namespace std;
int main
{
int a;
cin >> a;
return a && (a & (a - 1)) == 0);
return 0;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question