z_18n9di92n @ 2024-07-16 19:19:16
#include<bits/stdc++.h>
using namespace std;
int n,r;
string a[]={"0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","","R","S","T","U","V","W","X","Y","Z"};
string b[10005];
int main(){
cin>>n>>r;
int i=0;
while(n){
b[i]=a[n%r];
n/=r;
++i;
}
for(int j=i;j>=0;--j){
cout<<b[j];
}
return 0;
}
by DfsIJK_Juruo @ 2024-07-16 19:28:01
你的a数组里Q和R之间空了一位,把那个空的地方删了试一试
by DfsIJK_Juruo @ 2024-07-16 19:31:03
还有,string不能这么定义,应该写成这样:
string a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
b直接定义成这样就行了:
string b;
by z_18n9di92n @ 2024-07-16 19:38:12
谢谢,已通过(^人^)