Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How can i get my code below to show Able was I, ere I saw Elba. a strict palindrome attributed to Napoleon A man, a
How can i get my code below to show Able was I, ere I saw Elba. a strict palindrome attributed to Napoleon
A man, a plan, a canal: Panama! an ordinary palindrome and a not palindrome fixed here is my code #include
#include
#include
#include
#include
using namespace std;
bool isordinarypalindromeconst string& str
make a copy of the input string in which punctuation and spaces are removed and all text is lower case
string copy;
for char c : str
if isalnumc check if the character is alphanumeric
copy tolowerc locale::classic; append the lower case version of the character to the new string using the default locale
make another copy of the input string in which all text is lower case
string lower str;
for char& c : lower
c tolowerc locale::classic; convert each character to lower case using the default locale
reverse the second copy
reverselowerbegin lower.end;
compare the first copy with the second copy
return copy lower;
bool isstrictpalindromeconst string& str
make a copy of the input string in which all text is lower case
string lower str;
for char& c : lower
c tolowerc locale::classic; convert each character to lower case using the default locale
make another copy of the input string
string reversed lower;
reverse the copy
reversereversedbegin reversed.end;
compare the input string with the reversed copy
return lower reversed;
bool isnotpalindromeconst string& str
return the opposite of the ordinary palindrome check
return isordinarypalindromestr;
int main
string input;
do
cout "Please enter a string Q to quit: ;
getlinecin input;
if input Q
break;
if isordinarypalindromeinput
cout "The string is an ordinary palindrome." endl;
else if isstrictpalindromeinput
cout "The string is a strict palindrome." endl;
else if isnotpalindromeinput
cout "The string is not a palindrome." endl;
while true;
return ;
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