void chaju(int a)
{
int i = 0;
printf("奇数位\n");
for ( i = 30; i >=0; i-=2)
{
printf("%d ", (a >> i) & 1);
}
printf("\n");
printf("偶数位\n");
for (i = 31; i >=1; i-=2)
{
printf("%d ", (a >> i) & 1);
}
printf("\n");
//while (c)
//{
// c = c&(c - 1);
// set1++;
//}
/*int set1 = 0;
int i = 0;
for ( i = 0; i < 32; i++)
{
if (1 == ((c >> i) & 1))
set1++;
}*/
}
int main()
{
int num1 = 0;
int num2 = 0;
int num3 = 0;
printf("请输入:>");
scanf("%d", &num1);
chaju(num1);
return 0;
}
相关文章
- 03-27打印一个数二进制位里面偶数和奇树的位数