Question: C++ Programming!!!! - The palindrome determines whether a string reads the same forward and backward. For example, the string Able was I ere I saw
C++ Programming!!!! - The palindrome determines whether a string reads the same forward and backward. For example, the string Able was I ere I saw Elba is considered a palindrome if we treat both the upper- and lowercase versions of a letter as being the same character. This version of definition of palindrome is actually a string-level palindrome.
In this exercise, you are required to realize word-level palindrome checker program, which means if each word in the input string reads the same forward and backward, then the input string is considered as a word-level palindrome. For example, aba abba is not a string-level palindrome, but it is a word-level palindrome.
Sample Output:
Enter a line and I will see if it's a word-level palindrome:
Able was I ere I saw Elba.
Output: That is not a word-level palindrome.
Enter a line and I will see if it's a word-level palindrome:
aba abba
That is a word-level palindrome.
Enter a line and I will see if it's a word level palindrome:
Aa bB
That is a word-level palindrome.
Here is the code I have so far! But it doesn't determine if it's a word level Palidrome and thats what I need!!! Will rate! Please help! C++ Programming!!!!
#include
#include
#include
#include
#include
using namespace std;
int main()
{
queue
stack
char letter;
queue
cout << "Enter a line and I will see if it's a palindrome:" << endl;
while (cin.peek() != ' ')
{
cin >> letter;
if (isalpha(letter))
{
q.push(toupper(letter));
s.push(toupper(letter));
}
}
while ((!q.empty()) && (!s.empty()))
{
if (q.front() != s.top())
++mismatches;
q.pop();
s.pop();
}
if (mismatches == 0)
cout << "That is a palindrome." << endl;
else
cout << "That is not a palindrome." << endl;
cin.ignore(2);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
