Any help is appreciated.Here's my code:
#include <iostream>
#include <string>
#include "Stack.h"
#include "Queue.h"
int main()
{
Stack<char> s;
Queue<char> q;
bool palindrome = true;
char input = ' ';
//retrieve data from user
cout <<"Enter the word you wish to test: ";
//enqueue and dequeue word
while(cin.get(input) && input != '\n')
{
q.enqueue(toupper(input));
s.push(toupper(input));
}
// validate if palindrome
while( (!q.isEmpty() && !s.empty()) && palindrome)
{
if(q.getFront(input) == s.getTop(input))
{
q.dequeue(input);
s.pop();
}
else
{
palindrome = false;
}
}
// display results to the screen
if(palindrome == false)
{
cout << input <<" is not a palindrome!\n";
}
else
{
cout<< input << " is a palindrome! \n";
}
return 0;
}

New Topic/Question
Reply



MultiQuote





|