9. Palindrome Number go语言

go 语言

func isPalindrome(x int) bool {
    
    s := strconv.FormatInt(int64(x), 10)
    len_s := strings.Count(s,"") - 1
    
    for i,j := 0,len_s - 1; i < j; i, j = i + 1,j - 1  {
        if s[i] != s[j] {
            return false
        }    
    }
    return true
}

猜你喜欢

转载自blog.csdn.net/dyd961121/article/details/81216493