提交时间:2024-01-02 13:52:30

运行 ID: 118939

#include<bits/stdc++.h> using namespace std; string s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main() { stack<char> b; int n,d; cin>>n>>d; if(n==0){ cout<<0; return 0; } while(n!=0){ if(n%d<10) b.push((n%d)+'0'); else b.push(s[n%d-10]); n/=d; } while(b.empty()!=1){ cout<<b.top(); b.pop(); } return 0; }