#include <iostream>
#include <stack>
void convert(std::stack<char> &s,__int64 n, int base)
{
static char digit[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while (n > 0)
{
s.push(digit[n % base]);
n /= base;
}
}
int main()
{
std::stack<char> s;
convert(s,102413,16);
int len = s.size();
for (auto i = 0; i < len; i++)
{
std::cout<<s.top();
s.pop();
}
std::cout<<std::endl;
}
c++进制转换
最新推荐文章于 2024-04-01 13:13:51 发布