C/C++判断回文整数

C/C++判断回文整数

例如:整数 int x = 121; 正着读为121,反着读也为121; 是回文数 true
整数 int y = 1212; 正着读为1212, 反正读为2121;不是回文数 false

int checkPlain(int x)
{
    
    
    int a = 0, b = 0;
    a = x;
    while(a >0){
    
    	
         b = b*10 + a%10;
         a /=10;
    }
    if( b == x)
        return 1;
    else
        return 0;
}

猜你喜欢

转载自blog.csdn.net/c13055215176/article/details/114587077
今日推荐