给你个m进制数要你转换为n进制数。
(2<=m,n<=10)
解
先转换为10进制,再转换成其它。
代码
#include<cstdio>
int m, n, t, w[1001];
long long x, X, kkk;
int main(){
freopen("tool.in","r",stdin);
freopen("tool.out","w",stdout);
scanf("%lld%d%d", &x, &m, &n);
if(m != 10){
kkk = 1;
while(x){
X += x % 10 * kkk;
//SB!我比赛时这里的加号忘记打了!!!!啊!
kkk = kkk * m;
x /= 10;
}
}
else X = x;
while(X){
w[++t] = X % n;
X /= n;
}
while(t)
printf("%1d", w[t--]);
fclose(stdin);
fclose(stdout);
}