题目
相比于之前回文的处理方法,这次是我看到了新的方式,于是做一个记录。
#include <iostream>
using namespace std;
bool symm(unsigned n)
{
unsigned i=n;
unsigned m=0;
while(i>0)
{
m=m*10+i%10;
i/=10;
}
return m==n;
}
int main()
{
int n;
cout<<"please enter an integer to determine whether it is palindrome"<<endl;
cin>>n;
if(symm(n))
cout<<"yes"<<endl;
else
cout<<"no"<<endl;
return 0;
}