Advertisement
Guest User

Untitled

a guest
Sep 11th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement