#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; }
#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; }