Refer the previous problem. In that problem, the definition of palindromes was r
ID: 3621746 • Letter: R
Question
Refer the previous problem. In that problem, the definition of palindromes was restricted to just perfect palindromes-every letter and blank exactly the same in both forward and backward versions. Now using arrays, expand the definition to ignore blanks, punctuations, and letter case. Thusmadam I'm Adam
becomes
madamimadam
which is now a plaindrome. Write a C++ program that reads a line of input and checks wheter it is a palindrome on the basis of this less restrictive definition. Output the reversed line, with all blanks and puncutation removed, and all letters converted to lowercase along with the program's decision.
I already have this part:
#include<iostream>
#include<string>
using namespace std;
int main ()
{
string str;
cout << "Enter string: " << endl;
getline(cin,str);
cout << endl;
string str2, str3;
int p=1;
int k = str.length()-1;
int y = k;
for(int i = 0; i <= (str.length()-1); i++,k--)
{
str2 = str.substr (i,1);
str3 = str.substr (k,1);
cout << str2 << str3 << endl;
if(str2.compare(str3)!=0)
{
p=0;
break;
}
}
if(p)
cout << endl << str << ": is a palindrome." << endl << endl;
else
cout << endl << str << ": is not a palindrome." << endl << endl ;
system("PAUSE");
return 0;
}