标签:push ima stream alt empty 技术 src iostream int
//十进制转任意进制
#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;
}
运行测试:

标签:push ima stream alt empty 技术 src iostream int
原文地址:https://www.cnblogs.com/clwsec/p/11565447.html