fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool is_palindrome(int num){
  5. string Snum= to_string(num);
  6. int n=Snum.size();
  7. for(int i=0,j=n-1;i<=j;i++,j--)
  8. if(Snum[j]=='0') {
  9. i--;
  10. continue;
  11. }
  12. else if(Snum[i]!=Snum[j])
  13. return false;
  14. return true;
  15. }
  16.  
  17. int main(){
  18. int n; cin>>n;
  19. cout<<(is_palindrome(n)==1?"Yes\n":"No\n");
  20. }
Success #stdin #stdout 0s 5444KB
stdin
Standard input is empty
stdout
No