Ask your own question, for FREE!
Computer Science 19 Online
OpenStudy (anonymous):

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.

OpenStudy (konradzuse):

still need help?

OpenStudy (anonymous):

yes please

OpenStudy (konradzuse):

Lucky I was in the closed section :P

OpenStudy (konradzuse):

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.

OpenStudy (konradzuse):

Now you can do this with 3 stacks, or even 2.

OpenStudy (konradzuse):

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.

OpenStudy (konradzuse):

then you can see with the peek value if they are the same, then keep popping.

OpenStudy (anonymous):

Okay, shall i put it into struct?

OpenStudy (konradzuse):

not sure what that is, but I'm also not too familar with C.

OpenStudy (anonymous):

ahaaa, okaayy thank you so much :$

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!