Question: I need it to show correct ouput when the string is this it should be strict Able was I, ere I saw Elba. and it
I need it to show correct ouput when the string is this it should be strict Able was I, ere I saw Elba. and it should show ordinary when it is and not a palindrome when it isnt here please modify it#include
#include
#include
using namespace std;
using namespace std;
A function to check if a string is a strict palindrome
A strict palindrome is a string that is the same when reversed, without ignoring any characters
int isstrictpallindromeint start, int end, string& str
if start end
return ;
if strstart strend
return ;
return isstrictpallindromestart, end, str;
A function to check if a string is an ordinary palindrome
An ordinary palindrome is a string that is the same when reversed, ignoring case and nonalphanumeric characters
int isordinarypallindromeint start, int end, string& str
while start end
Skip nonalphanumeric characters
while start end && isalnumstrstart
start;
while start end && isalnumstrend
end;
Compare the characters after converting to lower case
if tolowerstrstart tolowerstrend
return ;
start;
end;
return ;
A function to check if a string is not a palindrome
A string is not a palindrome if it is neither a strict nor an ordinary palindrome
int isnotpallindromeint start, int end, string& str
return isstrictpallindromestart end, str && isordinarypallindromestart end, str;
int main
string str;
int start ;
int end;
int flag;
cout "Enter the string: ;
getlinecin str;
end strlength;
flag isstrictpallindromestart end str;
if flag
cout It is a strict palindrome" endl;
else
cout It is not a strict palindrome" endl;
flag isordinarypallindromestart end str;
if flag
cout It is an ordinary palindrome" endl;
else
cout It is not an ordinary palindrome" endl;
flag isnotpallindromestart end str;
if flag
cout It is not a palindrome" endl;
else
cout It is a palindrome" endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
