全红求助
查看原帖
全红求助
824718
xingyeyoumeng楼主2024/4/23 10:49
#include<iostream>
using namespace std;
#define maxsize 100000005
char a[maxsize];
int i = 0;
void base(int n,int x)
{
    if(n == 0) return;
    int rem;  //余数
    rem = n%x;
    char ch;
    if(rem>=10)
    {
        ch = rem%10+'A';
    }
    else
    {
        ch = rem+'0';
    }
    a[i++] = ch;
    n = (n - rem)/x;

    base(n,x);
}


int main()
{
    int n,x;
    cin  >> n >> x;
    base(n,x);
    for(int j = i;j>=0;j--)
    {
        cout << a[j];
    }

    return 0;
}
2024/4/23 10:49
加载中...