P1143 进制转换
这么一个憨批题居然还\(wa\)了几发?
int n,m;
string a,b;
int main()
{
cin>>n;
cin>>a;
cin>>m;
int res=0;
for(int i=0;i<a.size();i++)
{
if(isdigit(a[i])) res=res*n+(a[i]-'0');
else if(isupper(a[i])) res=res*n+(a[i]-'A'+10);
}
while(res)
{
if(res%m > 9) b+=res%m-10+'A';
else b+=res%m+'0';
res/=m;
}
reverse(b.begin(),b.end());
cout<<b<<endl;
//system("pause");
}