string change(int n,int x){
stack z;
string arr;
for(int j=1;j<=n;j++){
int t=j;
while(t){
z.push(t%x);
t/=x;
}
int i=0;
while(!z.empty()){
if(z.top()<10){
arr+=(‘0’+z.top());
}else if(z.top()==10){
arr+=(‘A’);
}else if(z.top()==11){
arr+=(‘B’);
}else if(z.top()==12){
arr+=(‘C’);
}else if(z.top()==13){
arr+=(‘D’);
}else if(z.top()==14){
arr+=(‘E’);
}else if(z.top()==15){
arr+=(‘F’);
}
z.pop();
}
}
看着玩的进制转化
最新推荐文章于 2022-11-21 23:59:52 发布