提交时间:2024-04-06 08:39:30
运行 ID: 141585
#include <iostream> #include <stack> using namespace std; stack <char> a; string h = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main() { int n, d; cin >> n >> d; while(n) { int t = n % d; char pushnum; if(t > 9) pushnum = h[t - 10]; else pushnum = char(t + '0'); a.push(pushnum); n /= d; } while(!a.empty()) { cout << a.top(); a.pop(); } cout << endl; return 0; }