提交时间:2025-12-19 20:48:12

运行 ID: 76805

#include <iostream> #include <cctype> using namespace std; void decToAny(int x, int m) { if (x == 0) { return; } int remainder = x % m; decToAny(x / m, m); if (remainder >= 10) { cout << (char)('A' + remainder - 10); } else { cout << remainder; } } int main() { int X, M; cin >> X >> M; if (X == 0) { cout << 0 << endl; return 0; } decToAny(X, M); cout << endl; return 0; }