#include<bits/stdc++.h>
using namespace std;
int n,r;
char zh(int x,int y){
if(x/y==0){
return 0;
}
int ans=x%y;
if(ans<0){
ans=ans-y;
x=x+y;
}
zh(x/y,y);
if(ans<=9){
cout<< ans;
}else{
cout<< char (ans+'A'-10);
}
}
int main(){
cin>>n>>r;
cout<<n<<"=";
if(n==0){
cout<<"0(base"<<r<<")"<<endl;
return 0;
}
zh(n,r);
cout<<"(base"<<r<<")"<<endl;
return 0;
}
输入#1时
我的输出是
30000=011010101110000(base-2)
剩下几个也一样。
大佬帮忙看看呗。WAW