判断回文数

如何判断回文数

1.转化为字符串,数位数,一个一个判,过于麻烦

2.将原数倒过来求他的逆数,然后判断是否等于原数------推荐

#include<iostream>
#include<cstdio>
using namespace std;
int hui(int n)
{
    int s,x=0;
    s=n;
    while(s)
    {
        x=x*10+s%10;
        s/=10;
    }
    if(n==x) return 1;
    else return 0;
}

posted @ 2020-03-01 23:02  Joelin12  阅读(139)  评论(0)    收藏  举报