In Von Neuman Loves Binary I have written my code mostly using bit manipulation, rather general arithmetic. Getting right ans for custom inputs, but when I am compiling and testing it, I am getting all ans as zeroes.
please help!
My code:
#include
using namespace std;
int main() {
int N;
cin>>N;
while(N--)
{
int b_no;
cin>>b_no;
int p = 1;
int ans = 0;
while(b_no > 0)
{
int digit = (b_no & 1);
if(digit == 1)
ans = ans + p;
p <<= 1;
b_no /= 10;
}
cout<<ans<<"\n";
}
return 0;
}
