提交时间:2024-04-06 08:22:53
运行 ID: 141562
#include<iostream> #include<stack> #include<cstdio> using namespace std; stack <int> stk; int main(){ int n,d; cin>>n>>d; if(n==0){ stk.push(0); } while(n>0){ int yushu=n%d; stk.push(yushu); n/=d; } while (!stk.empty()){ int TOP=stk.top(); if(TOP>=10){ printf("%c",(char)(TOP-10+'A')); } else{ cout<<TOP; } stk.pop(); } return 0; }