1. 程式人生 > >LeetCode9迴文數

LeetCode9迴文數

bool isPalindrome(int x) {
    int val = 0;
    int n;
    int y = x;
    if(x<0) return false;
    while(x){
        n = x%10;
        val = val * 10 + n;
        x /= 10;        
    }
    return (y == val);
}