LeetCode 第 14 场双周赛
Posted 菁芜·Firmamentfell
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode 第 14 场双周赛相关的知识,希望对你有一定的参考价值。
基础的 api 还是不够熟悉啊
5112. 十六进制魔术数字
class Solution {
public:
char *lltoa(long long num, char *str, int radix) {
const char index[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
unsigned long long unum;
int i = 0, j, k;
if(radix == 10 && num < 0) {
unum = (unsigned) - num;
str[i++] = '-';
} else
unum = (unsigned long long)num;
do {
str[i++] = index[unum % (unsigned)radix];
unum /= radix;
} while(unum);
str[i] = '