提交时间:2024-08-19 21:53:17
运行 ID: 168025
#include <iostream> using namespace std; int td(int num, int base) { int res = 0; int pow = 1; while (num > 0) { res += (num % 10) * pow; num /= 10; pow *= base; } return res; } void tb(int dec, int baseL) { if (dec == 0) { cout << 0 << endl; return; } string s = ""; while (dec > 0) { int r = dec % baseL; s = (r < 10? char(r + '0') : char(r - 10 + 'A')) + s; dec /= baseL; } cout << s << endl; } int main() { int k, n, l; while (cin >> k >> n >> l) { int d = td(n, k); tb(d, l); } return 0; }