The word palindrome is derived from the Greek palindromes, meaning running back again . A
palindrome is a word or phrase which reads the same in both directions. Some simple examples
are:
RACECAR DEED LEVEL PIP ROTOR CIVIC POP MADAM EYE NUN RADAR TOOT
Write a C++ function that checks recursively if a sentence is a palindrome (ignoring blanks,
lower- and uppercase differences, and punctuation marks so that “Madam, I'm Adam” is accepted
as a palindrome. Write a main program that tests your function.
work out what to put in your function by working out what it is going to do:
1) removes the spaces and punctuation from a std::string object (your sentence)
2) iterates over every pair of letters (first and last, 2nd and 2nd last, ...) until it reaches the middle
3) for each pair, check if the two letters are equal.
4) If you write the function to be something like this: bool isPalindrome (string sentence); then if they are not equal, you can just returnfalse;.
5) If it reaches the end of the loop, the string is a palindrome, so the function calls returntrue;.
yea that's way better to learn but cuz i need it asap for two hours thats why i have no enough time to understand every single thing but in the next time sure i will
- if characters that would be equal in a palindrome (1st and last, 2nd and 2nd last, etc to last and 1st) are not equal, it is not a palindrome, so return false.
- if all the character 'pairs' are equal, it will break the loop without returning, so return true.
Now all you need to do is write a main() function to test it.