题解 | #小乐乐与进制转换#
小乐乐与进制转换
https://www.nowcoder.com/practice/242eafef2a704c0ca130d563b7b3ee2d
#include <iostream>
#include <string>
using namespace std;
string DecToHex(int n)
{
string hex = "";
while (n)
{
int digit = n % 6;
hex = to_string(digit) + hex;
n /= 6;
}
return hex;
}
int main() {
int n;
cin >> n;
cout << DecToHex(n) << endl;
}
// 64 位输出请用 printf("%lld")


