Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. bool isPalindrome(int input) ///Testing input of 1234
  2. {
  3.     int i = input;
  4.     Stack inStack;
  5.     while (i > 0)
  6.     {
  7.         inStack.push(i % 10);
  8.         i /= 10;
  9.     }
  10.     int array[inStack.getCount()];
  11.     int tempSize = inStack.getCount();
  12.     for (int i = 0; i < inStack.getCount(); i++)
  13.     {
  14.         array[i] = inStack.pop();
  15.         cout << array[i] << " "; //input of 1234 gives me 1 2 here
  16.     }
  17.     cout << endl;
  18.     for (int i = 0; i < tempSize; i++)
  19.         if (array[i] != array[tempSize - i])
  20.             return false;
  21.     return true;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement