题解 | #数字颠倒#
数字颠倒
https://www.nowcoder.com/practice/ae809795fca34687a48b172186e3dafe
go 版本
package main import ( "fmt" "strconv" ) func main() { a := 0 n, _ := fmt.Scan(&a) if n == 0 { fmt.Println(a) return } else { res := "" for a != 0 { remainder := a % 10 a = a / 10 res += strconv.Itoa(remainder) } fmt.Println(res) } }
python版本
scan = input() print(scan[::-1])