Question
Hello I have an error with my C++ program when I try to debug it with the strings. The program needs to follow the requirements
Hello I have an error with my C++ program when I try to debug it with the strings. The program needs to follow the requirements stated below. Thanks.
Requirements:
Code:
#include
#include
using namespace std;
bool isPalindrome(const string& input)
{
if (input.length()
{
return true;
}
else if (input.at(0) != input.at(input.length() - 1))
{
return false;
}
else
{
return isPalindrome(input.substr(1, input.length() - 2));
}
}
int main()
{
int i,j;
int count;
string testStrings[6] =
{ "ABLE WAS I ERE I SAW ELBA",
"FOUR SCORE AND SEVEN YEARS AGO",
"NOW IS THE TIME FOR ALL GOOD MEN",
"DESSERTS I STRESSED",
"A MAN A PLAN A CANAL PANAMA",
"KAYAK" };
string newStrings;
for ( i = 0; i
{
cout
count=0;
newStrings="";
for( j=0;j if(isalnum(testStrings[i][j])) { newStrings[count++]=tolower(testStrings[i][j]); } else{ continue; } } if (isPalindrome(newStrings)) cout else cout } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started