Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
111619 胡盛哲 十进制转R进制 C++ Accepted 1 MS 276 KB 575 2025-03-02 18:28:08

Tests(10/10):


Code:

#include <iostream> #include <string> using namespace std; string convertToBase(int num, int base) { if (num == 0) { return "0"; } string result = ""; while (num > 0) { int remainder = num % base; if (remainder < 10) { result = char(remainder + '0') + result; } else { result = char(remainder - 10 + 'A') + result; } num /= base; } return result; } int main() { int x, r; cin >> x >> r; cout << convertToBase(x, r) << endl; return 0; }