题目:
题解:
func convertToBase7(num int) string {if num == 0 {return "0"}negative := num < 0if negative {num = -num}s := []byte{}for num > 0 {s = append(s, '0'+byte(num%7))num /= 7}if negative {s = append(s, '-')}for i, n := 0, len(s); i < n/2; i++ {s[i], s[n-1-i] = s[n-1-i], s[i]}return string(s)
}