Palindrom string - a solution
#include <iostream>
#include<string>
using namespace std;
int main()
{
string s, s1, t;
int d, j=0;
int subtraction='a'-'A'; //the difference in the code between lowercase and uppercase
char x,y;
getline(cin,s); //Loads text
d=s.length(); //text length
s1=s;
for(int i=0; i<d; i++) //passes through all the characters
{
if(s[i]==' ' || s[i]=='.' || s[i]==';' || s[i]==',' || s[i]=='?' || s[i]=='(' || s[i]==')' || s[i]=='!')continue; //These characters skip
if(s[i]>='A' && s[i]<='Z') //If they are big letters
{
y=s[i]+subtraction; //converts to a lowercase letter
s1[j++]=y; //Remember the letter in the array s1
}
else //If they are big letters
{
x=s[i];
s1[j++]=x; //Remember the letter in the array s1
}
}
bool palindrom=true;
cout<<endl;
for(int i=0; i<j/2; i++)
{
if(s1[i]!=s1[j-1-i]) //compare the current letter and the corresponding symmetric letter, and if different, it is not a
{ //palindrome
palindrom=false;
}
}
if(palindrom && j>0)
{
cout<<"yes"<<endl;
}
else
{
cout<<"Not"<<endl;
}
return 0;
}
#include<string>
using namespace std;
int main()
{
string s, s1, t;
int d, j=0;
int subtraction='a'-'A'; //the difference in the code between lowercase and uppercase
char x,y;
getline(cin,s); //Loads text
d=s.length(); //text length
s1=s;
for(int i=0; i<d; i++) //passes through all the characters
{
if(s[i]==' ' || s[i]=='.' || s[i]==';' || s[i]==',' || s[i]=='?' || s[i]=='(' || s[i]==')' || s[i]=='!')continue; //These characters skip
if(s[i]>='A' && s[i]<='Z') //If they are big letters
{
y=s[i]+subtraction; //converts to a lowercase letter
s1[j++]=y; //Remember the letter in the array s1
}
else //If they are big letters
{
x=s[i];
s1[j++]=x; //Remember the letter in the array s1
}
}
bool palindrom=true;
cout<<endl;
for(int i=0; i<j/2; i++)
{
if(s1[i]!=s1[j-1-i]) //compare the current letter and the corresponding symmetric letter, and if different, it is not a
{ //palindrome
palindrom=false;
}
}
if(palindrom && j>0)
{
cout<<"yes"<<endl;
}
else
{
cout<<"Not"<<endl;
}
return 0;
}