I'm stuck on a program. I need to prompt for the user to enter a potential palindrome ( so the usual cout cin right?) Read the user input in to a string object (the test input to your program may contain spaces but will not contain punctuation or mixed-case letters) // not sure what exactly its asking
Write a message stating that the input was or was not a valid palindrome
Your program may assume that all characters are in one case and that the input does not contain any punctuation (aside from spaces)
I'm given the following to remove spaces:
1 2 3 4 5 6
int x = s.find(' ');
while(x != -1 && x < (signed)s.size())
{
s.erase(x, 1);
x = s.find(' ');
}
an idea might be to have a list of palindromes in an array that a reference can compare to. Otherwise this seems to be extremely complicated since everything has to be set in order to be compared to and without a formula for setting such a sequence with unknown size sounds quite complicated. ^_^ It could be easier to set a palindrome size limit or just a simple word like godsdog compared to something extreme like go hang a salami im a lasagna hog Some sort of symmetrical formula would be of interest here. :)
possibly a limit like : 123456789
that could be reversed to match 987654321 reversing strings.
then you would have to somehow take into account "whitespace" or where the empty spaces resolve and then disregard them.