0pts,help!
查看原帖
0pts,help!
1095806
Supa7onyz楼主2024/4/14 10:51
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int n,x;
vector<char>ans;
char get(int num){
    string s="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return s[num];
}
int main()
{
    cin>>n>>x;
    cout<<n<<"=";
    while (n!=0){
        int a=n%x;
        n/=x;
        if (a<0){
            a-=x;
            n++;
        }
        ans.push_back(get(a));
    }
    for (int i=ans.size();i>=0;i--){
        cout<<ans[i];
    }
    cout<<"(base"<<x<<")";
    return 0;
}```
2024/4/14 10:51
加载中...