​Example "Palindrom" solution

#include <iostream>
#include<math.h>
using namespace std;


int main()
{
int n, len=0, p, k;
cin>>n;
bool rez=true;
int x=n;
do                                          //Determines the length of the number
    {
        x=x/10;
        len++;
    }
while(x>0);
if(len>1)
    {


for(int i=0; i<len/2; i++)
        {
            p=n%10;
            k=n/(int)pow(10,len-1);
            if(p!=k)rez=false;                              //If the symmetric digits are different then it is not a palindrome
        }
    }
if(rez)
    {
cout<<"Yes"<<endl;
    }
else
    {
cout<<"No"<<endl;
    }
return 0;
}
Back