回答:
代码语言:javascript复制#define CHAR_BITS 8 // size of character
#define INT_BITS ( sizeof(int) * CHAR_BITS) //bits in integer
void PrintInBinary(unsigned n)
{
char Pos = (INT_BITS -1);
for (; Pos >= 0 ; --Pos)
{
(n & (1 << Pos))? printf("1"): printf("0");
}
}