当前位置: 技术问答>linux和unix
10进制和16进制的数有直接转换的函数吗?或者怎么做编码?
来源: 互联网 发布时间:2015-07-09
本文导语: rt | 自己写个吧(大意): main() { int iDec; cin>>iDec; int iDevisor;//除数 int iRemainder; //余数 iDevisor = iDec/16; iRemainder = iDec%16; stack.push(iRemainder); //余数入栈 while (...
rt
|
自己写个吧(大意):
main()
{
int iDec;
cin>>iDec;
int iDevisor;//除数
int iRemainder; //余数
iDevisor = iDec/16;
iRemainder = iDec%16;
stack.push(iRemainder); //余数入栈
while (iDevisor>16)
{
iDevisor = iDevisor/16;
iRemainder = iRemainder%16;
stack.push(iRemainder);
}
stack.push(iDevisor);
while(!stack.empty())
{
int data = stack.pop();
switch(data)
{
case 10: cout
main()
{
int iDec;
cin>>iDec;
int iDevisor;//除数
int iRemainder; //余数
iDevisor = iDec/16;
iRemainder = iDec%16;
stack.push(iRemainder); //余数入栈
while (iDevisor>16)
{
iDevisor = iDevisor/16;
iRemainder = iRemainder%16;
stack.push(iRemainder);
}
stack.push(iDevisor);
while(!stack.empty())
{
int data = stack.pop();
switch(data)
{
case 10: cout