给定一个整数,判断该数是否是回文数

#include <iostream>
using namespace std;
bool judge(int n)
{
int help=1;
while(n/help>=10)
help*=10;
while(n!=0)
{
if(n/help!=n%10)
{
return false;
break;
}
n=(n%help)/10;
help/=100;
}
return true;
}
int main()
{
int n;
cin>>n;
bool res=judge(n);
cout<<res;
system("pause");
    return 0;
}

猜你喜欢

转载自blog.csdn.net/lidanyang666/article/details/80365274