#include<stack>
using namespace std;
void Convert(int n)
{
stack<int> stackdata;
while(n)
{
stackdata.push(n%2);
n=n/2;
}
while(!stackdata.empty())
{
cout<<stackdata.top();
stackdata.pop();
}
}
//这个函数只要在参数中加入一个表示多少进制的整数,并替换程序中的2即可转化为其他进制
本文介绍了如何使用C++语言实现一个通用的算法,将输入的十进制整数转换为指定进制的数字表示。通过使用堆栈数据结构,该算法能够灵活地处理不同进制的转换需求。
6051

被折叠的 条评论
为什么被折叠?



