返回题解分享
讨论 / 题解分享/ 帖子详情

十进制转K进制 - 题解

// https://dashoj.com/p/95
#include <bits/stdc++.h>

using namespace std;

int s, base;

int main() {
	cin >> s >> base;
	char digits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	string result;
	while (s != 0) {
		result.push_back(digits[s % base]);
		s /= base;
	}
	reverse(result.begin(), result.end());
	cout << result << endl;
	return 0;
}
0 回复 0 转发 0 喜欢 1 阅读
回复 (0)
默认 最新
暂无回复,快来抢沙发!