/* * Use the recursion and the stack ADT to find strings of the form * w$w', where w' = reverse(w). */ #include #include "C6-StackA.h" using namespace std; int recogStack(string str); int recogRecursion(string str, int index); int main() { string str; int result; cout << "Enter a string of for w$w', where w'=reverse(w): "; cin >> str; // Check for empty string if(str.length() == 0) return 0; // Recognize pattern using recursion cout << "Using recursion, the pattern is: "; result = recogRecursion(str, 0); cout << result << endl; // Recognize pattern using Stack ADT cout << "Using stack ADT, the reverse string is: "; result = recogStack(str); cout << result << endl; return 0; } /* * Recursive routine to recognize pattern w$w' */ int recogRecursion(string str, int index) { return 0; } /* * Use stack to recognize pattern w$w' */ int recogStack(string str) { Stack stklist; char c; int i; // push each character on the LIFO stack for(i=0 ; i