回文数,c++,用函数之前内容解决

img


#include<stdio.h>

int IsPalindrome(int x) {
    if(x < 0)   return false;
    int t = x,c = 0;
    while(t>0)
    {
        c = c*10 + t%10;
        t /= 10;
    }
    return c == x;
}


int main()
{
    long long int n;
    scanf("%d",&n);
    int res=IsPalindrome(n);
    
    printf("%d\n",res);
    
    return 0;
}