Urbosa @ 2024-08-25 11:58:15
本来应该输出4N,但输出4M
代码:
#include <bits/stdc++.h>
using namespace std;
long long x[11451],i,n,g,jz,cnt;
int main() {
cin>>n;
cin>>jz;
for(i=1;i<=99999;i++){
cnt++;
g=n;
x[i]=g%jz;
n/=jz;
if(n==0){
break;
}
}
for(long long k=cnt;k>=1;k--){
if(x[k]>=0&&x[k]<10){
cout<<x[k];
}
if(x[k]==10){
cout<<"A";
}
if(x[k]==11){
cout<<"B";
}
if(x[k]==12){
cout<<"C";
}
if(x[k]==13){
cout<<"D";
}
if(x[k]==14){
cout<<"E";
}
if(x[k]==15){
cout<<"F";
}
if(x[k]==16){
cout<<"G";
}
if(x[k]==17){
cout<<"H";
}
if(x[k]==18){
cout<<"I";
}
if(x[k]==19){
cout<<"J";
}
if(x[k]==20){
cout<<"K";
}
if(x[k]==21){
cout<<"L";
}
if(x[k]==22){
cout<<"N";
}
if(x[k]==23){
cout<<"M";
}
if(x[k]==24){
cout<<"O";
}
if(x[k]==25){
cout<<"P";
}
if(x[k]==26){
cout<<"Q";
}
if(x[k]==27){
cout<<"R";
}
if(x[k]==28){
cout<<"S";
}
if(x[k]==29){
cout<<"T";
}
if(x[k]==30){
cout<<"U";
}
if(x[k]==31){
cout<<"V";
}
if(x[k]==32){
cout<<"W";
}
if(x[k]==33){
cout<<"X";
}
if(x[k]==34){
cout<<"Y";
}
if(x[k]==35){
cout<<"Z";
}
}
return 0;
}
by 天南星魔芋 @ 2024-08-25 12:01:50
@Urbosa M
N
顺序反了吧 不是 HIJKLMN
吗?
by HASPID @ 2024-08-25 12:07:27
大于10可以直接char(x[k]+55),你可以试试
by Urbosa @ 2024-08-25 12:08:42
感谢各位大神帮助,已关!