Write a program that uses a stack object to determine if a string is a palindrome (i.e. the string is spelled identically backward and forward). The program should ignore spaces and punctuation.
Go ahead and start your program by reading in a C-style string from standard input, using the getline function. You may assume a limit of 100 characters on the string (although this can be written, with a little more effort, to accept any size string). Your algorithm must make use of a stack (of type char). Use the Deitel implementation of the Stack from stack.h (you dont need to change this file).
Ignore spacing and punctuation, as well as special characters and digits (i.e. only count letters as part of a palindrome, and account for upper/lower case. For example, B and b are matching letters).
Sample runs: (user input underlined)
Please enter a string: > ABCDEFGHGFEDCBA "ABCDEFGHGFEDCBA" IS a palindrome Please enter a string: > The quick brown fox "The quick brown fox" is NOT palindrome Please enter a string: > Cigar? Toss it in a can. It is so tragic. "Cigar? Toss it in a can. It is so tragic." IS a palindrome
Reviews
There are no reviews yet.