Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Stack.h"
- using namespace std;
- bool IsPalindrome(Stack<char>& MyStack, const string& UserInput)
- {
- for (int Count = 0; Count < UserInput.length(); ++Count)
- {
- if(Check(Count, UserInput))
- {
- char Extracted = MyStack.Pop();
- if (Extracted != UserInput[Count])
- return false;
- }
- }
- return true;
- }
- int main()
- {
- string UserInput;
- cout << "Please enter your string: "; cin >> UserInput;
- Stack<char> UserString(UserInput);
- if (IsPalindrome(UserString, UserInput))
- cout << "The string is palindrome" << endl;
- else
- cout << "The string is not palindrome" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement