第1个回答 2015-10-25
void TenToBinary(unsigned char cN)
{
unsigned char cTmp = cN;
for (int i=sizeof(unsigned char)*8-1; i>=0; i--)
{
putchar ( '0' + ((unsigned)(cTmp & (1<<i))>>i) );
}
}
void main()
{
int iN;
cout<<"Please Input a value:";
cin>>iN;
TenToBinary((unsigned char )iN);
cout<<endl;
}本回答被网友采纳