//反转整数。
//例1:X = 123,返回321
//例2:X = -123,返回-321
func reverse(x int) int {
str := strconv.Itoa(x)
strs := []string{}
result := ""
if x < 0 {
result = "-"
}
for _, info := range str {
s := fmt.Sprintf("%c", info)
if s == "-" {
continue
}
strs = append(strs, s)
}
for i := len(strs); i > 0; i-- {
result += strs[i-1]
}
response, err := strconv.Atoi(result)
if err != nil {
log.Fatal(err)
}
return response
}
func main() {
fmt.Print(reverse(45433566546657))
}