提交时间:2024-01-05 13:33:19

运行 ID: 119292

#include<iostream> #include<cstdlib> using namespace std; int s[111111]; int n,d,top=-1; int Push(int x) { top++;s[top]=x; } int Pop(int x) { if(s[top]>9) cout<<char(s[top]+55); else cout<<s[top]; x=s[top];top--; } int main() { cin>>n>>d; int top=-1,i=-1; if(n==0) cout<<"0"; else { while(n!=0) { Push(n%d); n/=d;i++; } while(i!=-1) { int tmp=n%d; Pop(tmp); i--; } } return 0; }