您的位置:首页 > 其它

将十进制转换成二进制 Convert decimal to binary

2014-03-13 22:59 274 查看
void ConvertDecimal2Bin(int dec)
{
vector<short> bin;
if(dec > 0)
{
int quotient = dec;
short remainder = dec;
while ( quotient != 0)
{
remainder = quotient % 2;
quotient = quotient / 2;
bin.push_back(remainder);
}
vector <short>::iterator  it = bin.end();
while(it != bin.begin())
cout << *(--it) << " ";
cout << endl;
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐