1、题目
https://leetcode-cn.com/problems/base-7/
2、题意
题解1:
class Solution {
public:
string convertToBase7(int num) {
if(num==0)
return "0";
string res;
bool sign = true;
if(num<0)
{
num = -num;
sign = false;
}
while(num)
{
res+='0'+num%7;
num/=7;
}
if(!sign)
res+='-';
return string(res.rbegin(),res.rend());
}
};