整数转成二进制含有一的个数
int num = 0;
while ((bt>>=1)!= 0)
{
num += bt & 1;
}
Console.WriteLine("该数有{0}个1", num);
while ((bt>>=1)!= 0)
{
num += bt & 1;
}
Console.WriteLine("该数有{0}个1", num);
本文来自博客园,作者:至道中和,转载请注明原文链接:https://www.cnblogs.com/voidobject/archive/2012/11/24/3975486.html