Using one or more stacks, write a C++ program to read in a string of characters and determine whether it forms a palindrome. A palindrome is a sequence of characters that reads the same both forward and backward. For example: aabbaa, abbcbba, and aaaaa are palindromes. You must assume that the data are correct and the maximum numbers of input characters is 80.
still need help?
yes please
Lucky I was in the closed section :P
Basically as you said above a palindrome is a word, like racecar, that is forward and backward. Now they say to do this with stacks.
Now you can do this with 3 stacks, or even 2.
push the word into the first one, then pop it and push into the second one, next you then push the same word into the first one again. Now you pop them both out and compare.
then you can see with the peek value if they are the same, then keep popping.
Okay, shall i put it into struct?
not sure what that is, but I'm also not too familar with C.
ahaaa, okaayy thank you so much :$
Join our real-time social learning platform and learn together with your friends!