using namespace std;
int main ()
{
int i;
int b0,b1,b2,b3,b4,b5,b6,b7;
cin >> i;
if (i > 0 && i <= 127)
{
b0 = i & 1;
b1 = (i >> 1) & 1;
b2 = (i >> 2) & 1;
b3 = (i >> 3) & 1;
b4 = (i >> 4) & 1;
b5 = (i >> 5) & 1;
b6 = (i >> 6) & 1;
b7 = (i >> 7) & 1;
cout << b7 << b6 << b5 << b4 << b3 << b2 << b1 << b0 << endl;
}
else if (i == 0)
{
cout << "00000000" << endl;
}
else if (i < 0 && i >= -128)
{
b0 = i & 1;
b1 = (i >> 1) & 1;
b2 = (i >> 2) & 1;
b3 = (i >> 3) & 1;
b4 = (i >> 4) & 1;
b5 = (i >> 5) & 1;
b6 = (i >> 6) & 1;
b7 = (i >> 7) & 1;
cout << b7 << b6 << b5 << b4 << b3 << b2 << b1 << b0 << endl;
}
return 0;
}
沒有留言:
張貼留言