提交时间:2023-12-30 11:00:31

运行 ID: 118409

#include<bits/stdc++.h> using namespace std; int main() { int n,t; char c; string s; cin>>n>>t; while(n!=0) { if(t==16) { if(n%16>=10) { c=n%16-10+'A'; } else { c=n%16+'0'; } }else{ c=n%t+'0'; } s=c+s; n=n/t; } if(s=="") { cout<<0; } else { cout<<s; } }