SHARE
TWEET

Untitled

a guest Sep 11th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "Stack.h"
  2.  
  3. using namespace std;
  4.  
  5. bool IsPalindrome(Stack<char>& MyStack, const string& UserInput)
  6. {
  7.     for (int Count = 0; Count < UserInput.length(); ++Count)
  8.     {
  9.         if(Check(Count, UserInput))
  10.         {
  11.             char Extracted = MyStack.Pop();
  12.             if (Extracted != UserInput[Count])
  13.                 return false;
  14.         }
  15.     }
  16.     return true;
  17. }
  18.  
  19. int main()
  20. {
  21.     string UserInput;
  22.     cout << "Please enter your string: "; cin >> UserInput;
  23.  
  24.     Stack<char> UserString(UserInput);
  25.    
  26.     if (IsPalindrome(UserString, UserInput))
  27.         cout << "The string is palindrome" << endl;
  28.     else
  29.         cout << "The string is not palindrome" << endl;
  30.  
  31.     return 0;
  32. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top