十进制转二进制
#include <iostream>
using namespace std;
int GetIntCount()
{
int n=255;
char Answer[8*sizeof(int)+1];
static int LEN=8*sizeof(int);
for (int i = LEN - 1; i >= 0; i--, n >>= 1)
Answer[i] = (01 & n) + '0';
Answer[LEN] = '\0';
string Str = Answer;
int nCount=0;
for(int i=0;i<LEN;i++)
{
if(1==Str[i]-48)
nCount++;
}
return nCount;
}
void main()
{
cout<<GetIntCount()<<endl;
getchar();
}