//十进制转任意进制
#include <iostream>
#include <stack>
using namespace std;
int main()
{
int T;
int n, a, p;
cin >> T;
while (T--)
{
stack<int> s;
//n 为十进制,p为要转换的进制
cin >> n >> p;
while (n)
{
a = n % p;
s.push(a);
n /= p;
}
while (!s.empty())
{
cout << s.top();
s.pop();
}
cout << endl;
}
system("pause");
return 0;
}
运行测试:
原文地址:https://www.cnblogs.com/clwsec/p/11565447.html
时间: 2024-10-16 19:27:31