#include #include #include

using namespace std;

string convertToBaseR(int N, int R) { string result;

while (N > 0) {
    int remainder = N % R;
    
    if (remainder < 10) {
        result += to_string(remainder);
    } else {
        result += char('A' + remainder - 10);
    }
    
    N /= R;
}

reverse(result.begin(), result.end());

return result;

}

int main() { int N, R; cin >> N >> R;

string baseR = convertToBaseR(N, R);

cout << baseR << endl;

return 0;

}

cpp题目描述题目描述小美刚刚学习了十六进制她觉得很有趣想到是不是还有更大的进制呢?在十六进制中用‘�A’表示 1010、‘�F’表示 1515。如果扩展到用‘�Z’表示 3535岂不是可以表示 3636 进制数了嘛!输入格式输入 22 行第一行包含一个正整数 �N第二行包含一个正整数 �R。保证 1≤�≤10000002≤�≤361≤N≤10000002≤R≤36输出格式输出 11 行为 �N

原文地址: http://www.cveoy.top/t/topic/jaWg 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录