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 is_strict_pallindrome(int start, int end, string& str)
{
if (start >= end)
return 1;
if (str[start]!= str[end])
return 0;
return is_strict_pallindrome(++start, --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 non-alphanumeric characters
int is_ordinary_pallindrome(int start, int end, string& str)
{
while (start < end)
{
// Skip non-alphanumeric characters
while (start < end && !isalnum(str[start]))
start++;
while (start < end && !isalnum(str[end]))
end--;
// Compare the characters after converting to lower case
if (tolower(str[start])!= tolower(str[end]))
return 0;
start++;
end--;
}
return 1;
}
// 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 is_not_pallindrome(int start, int end, string& str)
{
return !is_strict_pallindrome(start, end, str) && !is_ordinary_pallindrome(start, end, str);
}
int main()
{
string str;
int start =0;
int end;
int flag;
cout << "Enter the string: ";
getline(cin, str);
end = str.length();
flag = is_strict_pallindrome(start, end -1, str);
if (flag ==1)
cout <<"It is a strict palindrome" << endl;
else
cout <<"It is not a strict palindrome" << endl;
flag = is_ordinary_pallindrome(start, end -1, str);
if (flag ==1)
cout <<"It is an ordinary palindrome" << endl;
else
cout <<"It is not an ordinary palindrome" << endl;
flag = is_not_pallindrome(start, end -1, str);
if (flag ==1)
cout <<"It is not a palindrome" << endl;
else
cout <<"It is a palindrome" << endl;
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!