As I Was passing near the jail (line 1 matches line 8)
I met a man, but hurried by. (line 2 matches line 7)
His face was ghastly, grimly pale.
He had a gun I wondered why.
He had A gun I wondered why,
His face was ghastly, Grimly pale,
I met a man, but hurried by.
As I was passing near the jail
#include <iostream>
#include <string>
#include "linkedQueue.h"
#include "myStack.h"
#include "queueADT.h"
#include "stackADT.h"
using namespace std;
void TestCopyConstructor(stackType<int> otherStack);
bool checkifpalindrome(string a, string b, int y, int z);
int main()
{
linkedQueueType <string> myqueue;
stackType <string> mystack(200);
stackType <string> copystack(200);
mystack.initializeStack();
myqueue.initializeQueue();
string p;
int length = 0;
cout << "Enter the poem. When finished enter 007." << endl;
while( p != "007")
{
getline(cin,p); // gets the input from the user
for(unsigned int i = 0; i < p.length(); i++)
{
//remove(p.begin(), p.end(), " "); // removes the white space
if((p[i] >= 'a') && (p[i] <= 'z')) //derived from the ASCII Table
{
p[i] -= 32;
}
if(p[i] == ',') // made the program read commas as a period
{
p[i] = '.';
}
}
if(p != "007")
{
myqueue.addQueue(p); // adds string into the queue
mystack.push(p); // pushes it into stack
}
length++;
}
cout << endl << endl;
copystack = mystack; // duplicates mystack into the seperate stack
int z = 1;
while(!copystack.isEmptyStack()) //while stack is not empty
{
checkifpalindrome(copystack.top(), myqueue.front(), length-1, z);
myqueue.deleteQueue();
copystack.pop();
length--;
z++;
}
cout << endl;
copystack = mystack;
cout << endl;
return 0;
}
void testCopyConstructor(stackType<int> otherStack)
{
if(!otherStack.isEmptyStack())
{
cout << "The other stack is currently not empty." << endl;
cout << "The top element of the other stack is " << otherStack.top() << endl;
}
}
bool checkifpalindrome(string a, string b, int y, int z)
{
if(a == B)/>/>/>
{
cout << "Line " << y << " matches with line " << z << endl;
return true;
}
else
{
cout<< "Line "<< y << " does not match with line " << z << endl;
return false;
}
}

New Topic/Question
Reply



MultiQuote





|