回文数

#include <iostream>
using namespace std;
int main()
{
	int x;
	cin>>x;
	int k=0;
	int p=x;
	while(p!=0){
		k=k*10+p%10;
		p/=10;
	}
	if(x==k)
		cout<<"yes"<<endl;
	else
		cout<<"no"<<endl;
	return 0;
}

  其核心就是一个反转

while(p!=0){
        k=k*10+p%10;
        p/=10;
    }

 

posted @ 2016-10-09 10:37  FlyingJiang  阅读(207)  评论(0编辑  收藏  举报