这个博客已经停止更新,可以到我的个人博客来瞅瞅。
C++#include <bits/stdc++.h>
using namespace std;
int main(){
int qian;
string shu;
int hou;
cin>>qian>>shu>>hou;
int i=-1;
int he=0;
int len=shu.size();
for(i=0;i<len;i++){
if(shu[i]>='0' && shu[i]<='9'){
he=he+(int)(shu[i]-'0')*pow(qian,len-1-i);
}
if(shu[i]>='A' && shu[i]<='Z'){
he=he+(int)(shu[i]-'A'+10)*pow(qian,len-1-i);
}
}
//-------------
int a[1000];
i=-1;
while(he!=0){
i++;
a[i]=he%hou;
he=he/hou;
}
for(;i>=0;i--){
if(a[i]>=10){
cout<<(char)(a[i]+55);
}else{
cout<<a[i];
}
}
return 0;
}