mercredi 23 août 2017

I want to check whether a string is palindrome

char s[100];
//char t[100];
int count = 1;
int j=0;
int x,i;
cin >>s;
x=strlen(s);
//cout <<x <<endl;
cout <<s[j] <<endl;
i=x-1;
cout <<s[i] <<endl;
for (int i = x-1; i <= 0; i--)
{
    if (s[j] != s[i])
    {
        count = 0;
    }
    j++;

}
if ( count  )
{
    cout <<"YES";
}
else
{
    cout <<"NO";
}
return 0;

I Want to whether a given string is palindrome or not. Whats wrong with this code?

Aucun commentaire:

Enregistrer un commentaire