简答题 偏难
#22339

# include <iostream> # include <algorithm> using namespace std ; const int MAXL…

#include <iostream> 
#include <algorithm> 

using namespace std; 

const int MAXL = 1000; 

int n, k, ans[MAXL]; 

int main(void) 
{ 
    cin >> n >> k;
    if (!n) cout << 0 << endl; 
    else
    {
        int m = 0;
        while (n)
        {
            ans[m++] = (n % (-k) + k) % k; 20             n = (ans[m - 1] - n) / k; 
        }
        for (int i = m - 1; i >= 0; i--) 
            cout << char(ans[i] >= 10 ?
                ans[i] + 'A' - 10 : 
                ans[i] + '0');
        cout << endl;
    }
    return 0;
}


假设输入的 n 在 int 范围内,k 为不小于 2 且不大于 36 的正整数,完成下面的判断题和单选题:

未登录也能判分,登录后才会记录
答案与解析
正确答案:(缺答案,待补录)
这道题暂未补解析。