整体程序如下,为何我写出来以后运行发现输出位数不对呢?
#include <stdio.h>
void printBinary(int number);
int main()
{
printBinary(15);
return 0;
}
void printBinary(int number)
{
int temp = sizeof(number)<<3 - 1;
while(temp>=0)
{
int value = number>>temp & 1;
printf("%d",value);
temp--;
if ((temp+1)%4 == 0)
{
printf(" ");
}
}
printf("\n");
}
求大神解答{:3_49:} |
|