一个字符里有多少个1
#include<stdio.h>unsigned int CheckSetBitNum(char ucNumber);
int main()
{
char a = 'a';
printf("%d\n",CheckSetBitNum(a));
return 1;
}
unsigned int CheckSetBitNum(char ucNumber)
{
unsigned int i;
unsigned int Result = 0;
for(i = 0;i < 8;i++)
{
Result += (ucNumber & 0x01);
ucNumber = ucNumber >> 1;
}
return Result;
}
补充:综合编程 , 其他综合 ,