Palindrome.

A palindrome is a string that is equal to its reverse - "mom", "I", "radar", and "able was I ere I saw elba". Write a recursive Boolean function that determines whether its parameter is a palindrome. You should ignore whitespace and punctuation in the parameter. You may simply hard code the text that is then initially passed to the function.

I don't know where to start. anyone please help
I would start by writing the function prototype. What parameters is it going to take and what will it return?
You always have something to start with, even if it's only #include<iostream>
Hopefully it's more than that, but why don't you post what you have?
This wouldn't exactly be following your directions but what about first setting a string equal to something (like "radar"). Find the total size of the string using string::length or string::size. Load each of the letters into a vector of chars. If the length/size is odd, divide the length by two and use the floor function of that number. This will tell you where your middle character should be in the vector (like 'd' should be in vector[2] bc 5/2=2.5, floor that and get 2). Have two iterators, one going from the vector_name.begin and the other from the vector_name.end and compare the values (does vector[0]=vector[4]?) and continue. Use the similar method if the size was even.
Topic archived. No new replies allowed.